Skip to content

Commit

Permalink
Fix loop bounds validating struct without members
Browse files Browse the repository at this point in the history
An struct that inherits from another struct need not any members.  If the base type is not
known yet the validation code used (uint32_t) -1 as the loop bound.

Signed-off-by: Erik Boasson <[email protected]>
  • Loading branch information
eboasson committed Jun 18, 2024
1 parent 72b4f86 commit 24c6e8c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/ddsi/src/ddsi_typewrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,9 +640,9 @@ static dds_return_t xt_valid_struct_member_ids (struct ddsi_domaingv *gv, const
ids[--cnt1] = t1->_u.structure.members.seq[n].id;
}
qsort (ids, cnt, sizeof (*ids), xt_member_id_cmp);
for (uint32_t n = 0; n < cnt - 1; n++)
for (uint32_t n = 1; n < cnt; n++)
{
if (ids[n] == ids[n + 1])
if (ids[n] == ids[n - 1])
{
GVTRACE ("duplicate member id %"PRIu32" in struct\n", ids[n]);
ret = DDS_RETCODE_BAD_PARAMETER;
Expand Down

0 comments on commit 24c6e8c

Please sign in to comment.