Skip to content

In cbor2cjson.c example, add missing cbor_move to cbor_array_get call - #338

Merged
PJK merged 1 commit into
PJK:masterfrom
whitehse:master
Feb 21, 2025
Merged

PJK merged 1 commit into
PJK:masterfrom
whitehse:master

Conversation

@whitehse

Copy link
Copy Markdown
Contributor

Description

The cbor2cjson.c example contains a call to cbor_array_get, which increments the reference counter, that is not paired with a cbor_move or reference decrement.

I borrowed the cbor_to_cjson function in some test code that was exhibiting a memory leak, until I added a cbor_move call:

https://github.com/whitehse/testing/blob/master/ipfix/ipfix_server.c

There are two kinds of arrays in my test data. I don't know if one or both kinds are triggering an issue:

  • An array of maps - success &= cbor_array_push(array_of_templates, cbor_move(template));
  • An array of uint16's - success &= cbor_array_push(array_of_fields, cbor_move(cbor_build_uint16(field_type)));

Since this is example code, I have not updated any tests, documentation, or the CHANGELOG. There are no security or performance implications in this one-line change.

Checklist

  • I have read followed CONTRIBUTING.md
    • I have added tests
    • I have updated the documentation
    • I have updated the CHANGELOG
  • Are there any breaking changes?
    • If yes: I have marked them in the CHANGELOG (example)
  • Does this PR introduce any platform specific code?
  • Security: Does this PR potentially affect security?
  • Performance: Does this PR potentially affect performance?

@PJK

PJK commented Feb 21, 2025

Copy link
Copy Markdown
Owner

Good catch, thanks for the fix @whitehse !

@PJK
PJK merged commit 64491d8 into PJK:master Feb 21, 2025
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Mar 30, 2025
0.12.0 (2025-03-16)

- BUILD BREAKING: [Respect `INTERPROCEDURAL_OPTIMIZATION` and use the default value](PJK/libcbor#315)
- BREAKING: Changes to NaN encoding
  - [Fix NaN encoding on Windows](PJK/libcbor#271)
  - [Fix NaN encoding on mips/mipsel](PJK/libcbor#329)
  - [Signaling NaNs will from now on be encoded as canonical quiet NaNs](PJK/libcbor#335). This was already the existing behavior for half-precision floats
  - Decoding is unchanged
  - Please note that this is an intermediate state and likely to be revisited (PJK/libcbor#336)
- [Make build compatible with CMake FetchContent](PJK/libcbor#341) (by [Jan200101](https://github.com/Jan200101))
- [Support Bzlmod for Bazel builds](PJK/libcbor#340)
  - This should significantly simplify including libcbor as a dependency/module in Bazel projects, see https://bazel.build/external/migration
- Code quality improvements
  - [Fix compiler pragmas](PJK/libcbor#347) (by [brooksdavis](https://github.com/brooksdavis))
  - [Fix code style issues](PJK/libcbor#321)
- [Fixed bug in cbor2cjson example](PJK/libcbor#338)
msk pushed a commit to msk/pkgsrc that referenced this pull request May 11, 2026
0.12.0 (2025-03-16)

- BUILD BREAKING: [Respect `INTERPROCEDURAL_OPTIMIZATION` and use the default value](PJK/libcbor#315)
- BREAKING: Changes to NaN encoding
  - [Fix NaN encoding on Windows](PJK/libcbor#271)
  - [Fix NaN encoding on mips/mipsel](PJK/libcbor#329)
  - [Signaling NaNs will from now on be encoded as canonical quiet NaNs](PJK/libcbor#335). This was already the existing behavior for half-precision floats
  - Decoding is unchanged
  - Please note that this is an intermediate state and likely to be revisited (PJK/libcbor#336)
- [Make build compatible with CMake FetchContent](PJK/libcbor#341) (by [Jan200101](https://github.com/Jan200101))
- [Support Bzlmod for Bazel builds](PJK/libcbor#340)
  - This should significantly simplify including libcbor as a dependency/module in Bazel projects, see https://bazel.build/external/migration
- Code quality improvements
  - [Fix compiler pragmas](PJK/libcbor#347) (by [brooksdavis](https://github.com/brooksdavis))
  - [Fix code style issues](PJK/libcbor#321)
- [Fixed bug in cbor2cjson example](PJK/libcbor#338)
jperkin pushed a commit to TritonDataCenter/pkgsrc that referenced this pull request May 14, 2026
0.12.0 (2025-03-16)

- BUILD BREAKING: [Respect `INTERPROCEDURAL_OPTIMIZATION` and use the default value](PJK/libcbor#315)
- BREAKING: Changes to NaN encoding
  - [Fix NaN encoding on Windows](PJK/libcbor#271)
  - [Fix NaN encoding on mips/mipsel](PJK/libcbor#329)
  - [Signaling NaNs will from now on be encoded as canonical quiet NaNs](PJK/libcbor#335). This was already the existing behavior for half-precision floats
  - Decoding is unchanged
  - Please note that this is an intermediate state and likely to be revisited (PJK/libcbor#336)
- [Make build compatible with CMake FetchContent](PJK/libcbor#341) (by [Jan200101](https://github.com/Jan200101))
- [Support Bzlmod for Bazel builds](PJK/libcbor#340)
  - This should significantly simplify including libcbor as a dependency/module in Bazel projects, see https://bazel.build/external/migration
- Code quality improvements
  - [Fix compiler pragmas](PJK/libcbor#347) (by [brooksdavis](https://github.com/brooksdavis))
  - [Fix code style issues](PJK/libcbor#321)
- [Fixed bug in cbor2cjson example](PJK/libcbor#338)
tsutsui pushed a commit to tsutsui/pkgsrc that referenced this pull request Oct 17, 2026
0.12.0 (2025-03-16)

- BUILD BREAKING: [Respect `INTERPROCEDURAL_OPTIMIZATION` and use the default value](PJK/libcbor#315)
- BREAKING: Changes to NaN encoding
  - [Fix NaN encoding on Windows](PJK/libcbor#271)
  - [Fix NaN encoding on mips/mipsel](PJK/libcbor#329)
  - [Signaling NaNs will from now on be encoded as canonical quiet NaNs](PJK/libcbor#335). This was already the existing behavior for half-precision floats
  - Decoding is unchanged
  - Please note that this is an intermediate state and likely to be revisited (PJK/libcbor#336)
- [Make build compatible with CMake FetchContent](PJK/libcbor#341) (by [Jan200101](https://github.com/Jan200101))
- [Support Bzlmod for Bazel builds](PJK/libcbor#340)
  - This should significantly simplify including libcbor as a dependency/module in Bazel projects, see https://bazel.build/external/migration
- Code quality improvements
  - [Fix compiler pragmas](PJK/libcbor#347) (by [brooksdavis](https://github.com/brooksdavis))
  - [Fix code style issues](PJK/libcbor#321)
- [Fixed bug in cbor2cjson example](PJK/libcbor#338)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址