Archived
Parser: let cbor_value_leave_container() consume the Break
Instead of consuming it at the end of the last element of a map or array of unknown length. This allows us to obtain the pointer to or offset of the Break byte. Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
+5
-1
@@ -268,9 +268,9 @@ static CborError preparse_next_value_nodecrement(CborValue *it)
|
||||
/* but we weren't expecting it! */
|
||||
return CborErrorUnexpectedBreak;
|
||||
}
|
||||
advance_bytes(it, 1);
|
||||
it->type = CborInvalidType;
|
||||
it->remaining = 0;
|
||||
it->flags |= CborIteratorFlag_UnknownLength; /* leave_container must consume the Break */
|
||||
return CborNoError;
|
||||
}
|
||||
|
||||
@@ -286,6 +286,7 @@ static CborError preparse_next_value(CborValue *it)
|
||||
if (it->remaining != UINT32_MAX) {
|
||||
if (itemCounts && --it->remaining == 0) {
|
||||
it->type = CborInvalidType;
|
||||
it->flags &= ~CborIteratorFlag_UnknownLength; /* no Break to consume */
|
||||
return CborNoError;
|
||||
}
|
||||
}
|
||||
@@ -604,7 +605,10 @@ CborError cbor_value_leave_container(CborValue *it, const CborValue *recursed)
|
||||
{
|
||||
cbor_assert(cbor_value_is_container(it));
|
||||
cbor_assert(recursed->type == CborInvalidType);
|
||||
|
||||
copy_current_position(it, recursed);
|
||||
if (recursed->flags & CborIteratorFlag_UnknownLength)
|
||||
advance_bytes(it, 1);
|
||||
return preparse_next_value(it);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user