summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Baldin <ivan.baldin@gmail.com>2021-11-24 23:57:26 +0200
committerGitHub <noreply@github.com>2021-11-24 23:57:26 +0200
commit7440e7e63a3b3849e225fc88735c740477259faa (patch)
tree9e78501a88911f31b921195b223f1e0762e6a166 /src
parent155d91dcff889fc2a2ad91ce5cb3c3e751079be1 (diff)
Fix encoder null item error
Remaining item counter isn't being updated when encoding arrays and maps in normal mode leading to null item error.
Diffstat (limited to 'src')
-rw-r--r--src/libecbor/ecbor_encoder.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libecbor/ecbor_encoder.c b/src/libecbor/ecbor_encoder.c
index b144644..2b01094 100644
--- a/src/libecbor/ecbor_encoder.c
+++ b/src/libecbor/ecbor_encoder.c
@@ -239,7 +239,7 @@ ecbor_encode (ecbor_encode_context_t *context, ecbor_item_t *item)
size_t remaining = item->length;
ecbor_item_t *current = item->child;
- while (remaining) {
+ while (remaining--) {
/* write item */
if (!current) {
return ECBOR_ERR_NULL_ITEM;
@@ -559,4 +559,4 @@ ecbor_map (ecbor_item_t *map, ecbor_item_t *keys, ecbor_item_t *values,
}
return ECBOR_OK;
-} \ No newline at end of file
+}