You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2020/03/03 18:56:58 UTC

[mynewt-core] branch master updated: Fix json decoding of empty array

This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new f98ee55  Fix json decoding of empty array
f98ee55 is described below

commit f98ee5574f02df26745ffb38397defc39370f5c6
Author: Stefan Diewald <dw...@users.noreply.github.com>
AuthorDate: Fri Feb 28 09:33:41 2020 +0100

    Fix json decoding of empty array
    
    Without the fix, decoding an empty array leads to JSON_ERR_BADTRAIL.
    When peek is "positive", the read cursor needs to be forwarded to
    discard the closing "]".
    
    Signed-off-by: Stefan Diewald <dw...@users.noreply.github.com>
---
 encoding/json/src/json_decode.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/encoding/json/src/json_decode.c b/encoding/json/src/json_decode.c
index 8d39d24..81df9de 100644
--- a/encoding/json/src/json_decode.c
+++ b/encoding/json/src/json_decode.c
@@ -526,6 +526,7 @@ json_read_array(struct json_buffer *jb, const struct json_array_t *arr)
     json_skip_ws(jb);
 
     if (json_peek(jb) == ']') {
+        jb->jb_read_next(jb);
         goto breakout;
     }