Skip to content

Commit

Permalink
Avoid returning a pointer to internal storage of upb_MiniTable.subs.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 625544972
  • Loading branch information
haberman authored and copybara-github committed Apr 17, 2024
1 parent 7d24d5f commit 2a233df
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions upb/mini_table/internal/message.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct upb_MiniTable {
const char* UPB_PRIVATE(full_name);
#endif

#ifdef UPB_FASTTABLE_ENABLED
#if UPB_FASTTABLE
// To statically initialize the tables of variable length, we need a flexible
// array member, and we need to compile in gnu99 mode (constant initialization
// of flexible array members is a GNU extension, not in C99 unfortunately.
Expand Down Expand Up @@ -97,9 +97,9 @@ UPB_API_INLINE const struct upb_MiniTableField* upb_MiniTable_GetFieldByIndex(
return &m->UPB_ONLYBITS(fields)[i];
}

UPB_INLINE const union upb_MiniTableSub* UPB_PRIVATE(
UPB_INLINE const union upb_MiniTableSub UPB_PRIVATE(
_upb_MiniTable_GetSubByIndex)(const struct upb_MiniTable* m, uint32_t i) {
return &m->UPB_PRIVATE(subs)[i];
return m->UPB_PRIVATE(subs)[i];
}

UPB_API_INLINE const struct upb_MiniTable* upb_MiniTable_GetSubMessageTable(
Expand Down
2 changes: 1 addition & 1 deletion upb/wire/internal/decode_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ const char* fastdecode_tosubmsg(upb_EpsCopyInputStream* e, const char* ptr,
uint32_t submsg_idx = (data >> 16) & 0xff; \
const upb_MiniTable* tablep = decode_totablep(table); \
const upb_MiniTable* subtablep = upb_MiniTableSub_Message( \
*UPB_PRIVATE(_upb_MiniTable_GetSubByIndex)(tablep, submsg_idx)); \
UPB_PRIVATE(_upb_MiniTable_GetSubByIndex)(tablep, submsg_idx)); \
fastdecode_submsgdata submsg = {decode_totable(subtablep)}; \
fastdecode_arr farr; \
\
Expand Down

0 comments on commit 2a233df

Please sign in to comment.