Skip to content

Commit 4df8364

Browse files
Invert the way we account for the recursion level
This allows advance_recursive to be called with different levels when called directly. Signed-off-by: Thiago Macieira <[email protected]>
1 parent ed68cda commit 4df8364

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/cborparser.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ static CborError advance_recursive(CborValue *it, int nestingLevel)
486486
}
487487

488488
/* map or array */
489-
if (nestingLevel == CBOR_PARSER_MAX_RECURSIONS)
489+
if (nestingLevel == 0)
490490
return CborErrorNestingTooDeep;
491491

492492
CborError err;
@@ -495,7 +495,7 @@ static CborError advance_recursive(CborValue *it, int nestingLevel)
495495
if (err)
496496
return err;
497497
while (!cbor_value_at_end(&recursed)) {
498-
err = advance_recursive(&recursed, nestingLevel + 1);
498+
err = advance_recursive(&recursed, nestingLevel - 1);
499499
if (err)
500500
return err;
501501
}
@@ -522,7 +522,7 @@ CborError cbor_value_advance(CborValue *it)
522522
cbor_assert(it->type != CborInvalidType);
523523
if (!it->remaining)
524524
return CborErrorAdvancePastEOF;
525-
return advance_recursive(it, 0);
525+
return advance_recursive(it, CBOR_PARSER_MAX_RECURSIONS);
526526
}
527527

528528
/**

0 commit comments

Comments
 (0)