PJK / libcbor

CBOR protocol implementation for C
MIT License
341 stars 95 forks source link

Rework memory allocation failure handling in bytestring builders, add tests #242

Closed PJK closed 1 year ago

PJK commented 1 year ago

Description

The decoder should clean up intermediate items when the callback fails. The rest of the cleanup is handled by the decoder stack unwinding

Replaces #228. In retrospect, the fix wasn't a good solution: the new behavior did fix the memory leak in the streaming decoder, but the semantics didn't make sense for standalone usage of cbor_bytestring_add_chunk and were also inconsistent with cbor_array_push.

Fixes #231

Checklist

codecov-commenter commented 1 year ago

Codecov Report

Attention: Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Project coverage is 96.49%. Comparing base (118f8d3) to head (b7c04c2). Report is 271 commits behind head on master.

Files with missing lines Patch % Lines
src/cbor/internal/builder_callbacks.c 85.71% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #242 +/- ## ========================================== + Coverage 95.85% 96.49% +0.64% ========================================== Files 20 20 Lines 1544 1541 -3 ========================================== + Hits 1480 1487 +7 + Misses 64 54 -10 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

PJK commented 1 year ago

cc @James-ZHANG