From: Adam Sutton Date: Fri, 15 Jun 2012 10:40:01 +0000 (+0100) Subject: Fix json parsing to handle empty objects and ensure hm_ilist is properly set on htsms... X-Git-Tag: 3.0~18^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=11944f0933463e538f0479118952ad3493c0255f;p=thirdparty%2Ftvheadend.git Fix json parsing to handle empty objects and ensure hm_ilist is properly set on htsmsg_add_msg to allow some post load modifications. --- diff --git a/src/htsmsg.c b/src/htsmsg.c index c74a3afcc..6de14e4e9 100644 --- a/src/htsmsg.c +++ b/src/htsmsg.c @@ -258,6 +258,7 @@ htsmsg_add_msg(htsmsg_t *msg, const char *name, htsmsg_t *sub) assert(sub->hm_data == NULL); TAILQ_MOVE(&f->hmf_msg.hm_fields, &sub->hm_fields, hmf_link); + f->hmf_msg.hm_islist = sub->hm_islist; free(sub); } @@ -275,6 +276,7 @@ htsmsg_add_msg_extname(htsmsg_t *msg, const char *name, htsmsg_t *sub) assert(sub->hm_data == NULL); TAILQ_MOVE(&f->hmf_msg.hm_fields, &sub->hm_fields, hmf_link); + f->hmf_msg.hm_islist = sub->hm_islist; free(sub); } diff --git a/src/htsmsg_json.c b/src/htsmsg_json.c index 88cd0e313..a302247dc 100644 --- a/src/htsmsg_json.c +++ b/src/htsmsg_json.c @@ -233,7 +233,10 @@ htsmsg_json_parse_object(const char *s, const char **endp) r = htsmsg_create_map(); - while(1) { + while(*s > 0 && *s < 33) + s++; + + if(*s != '}') while(1) { if((name = htsmsg_json_parse_string(s, &s2)) == NULL) { htsmsg_destroy(r);