Bump version to 1.5.2 (#311)
* Bump version to 1.5.2
* Fix bug due to uninitialized variable in qcbor_decode.c (#313)
In QCBORDecode_Private_ConsumeItem pbBreak is not set when the array is
empty. As a result if the calling function passes an uninitialized
value and the array is empty, the function may assume that the last
character has to be removed.
The issue was noticed by the GetMapAndArrayTest failing with code 59.
Changelog:
- In the branch of empty array, explicitly set pbBreak to false
- Add pbBreak param to the function comment
Tests:
- All tests pass in debug and release mode
Co-authored-by: Jean-Philippe Lemieux <1141657+jpl-mac@users.noreply.github.com>
---------
Co-authored-by: Laurence Lundblade <lgl@securitytheory.com>
Co-authored-by: jpl-mac <jpl-mac@users.noreply.github.com>
Co-authored-by: Jean-Philippe Lemieux <1141657+jpl-mac@users.noreply.github.com>
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index 05e9c87..402683e 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -3139,6 +3139,8 @@
* @param[in] pMe The decoder context.
* @param[in] pItemToConsume The array/map whose contents are to be
* consumed.
+ * @param[out] pbBreak Set to true if extra break was consumed.
+ * Can be NULL.
* @param[out] puNextNestLevel The next nesting level after the item was
* fully consumed.
*
@@ -3178,8 +3180,11 @@
} else {
/* pItemToConsume is not a map or array. Just pass the nesting
- * level through. */
+ * level through. Ensure pbBreak is false. */
*puNextNestLevel = pItemToConsume->uNextNestLevel;
+ if(pbBreak) {
+ *pbBreak = false;
+ }
uReturn = QCBOR_SUCCESS;
}