<p>Joshua Colp <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/10322">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">jansson-bundled: Add patches to improve json_pack error reporting.<br><br>Change-Id: I045e420d5e73e60639079246e810da6ae21ae22b<br>---<br>A third-party/jansson/patches/0029-json_pack-Improve-handling-of-formats-with-and.patch<br>A third-party/jansson/patches/0030-More-work-on-json_pack-error-reporting.patch<br>2 files changed, 317 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/third-party/jansson/patches/0029-json_pack-Improve-handling-of-formats-with-and.patch b/third-party/jansson/patches/0029-json_pack-Improve-handling-of-formats-with-and.patch</span><br><span>new file mode 100644</span><br><span>index 0000000..fe86db8</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/jansson/patches/0029-json_pack-Improve-handling-of-formats-with-and.patch</span><br><span>@@ -0,0 +1,217 @@</span><br><span style="color: hsl(120, 100%, 40%);">+From 5df5fc5b13cac5212482d36e7f3a78951782cfb5 Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(120, 100%, 40%);">+From: Corey Farrell <git@cfware.com></span><br><span style="color: hsl(120, 100%, 40%);">+Date: Tue, 25 Sep 2018 14:31:56 -0400</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: [PATCH 29/30] json_pack: Improve handling of formats with '?' and</span><br><span style="color: hsl(120, 100%, 40%);">+ '*'.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Test updates have been removed for easier merging for bundled build.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+When NULL is received for an optional argument we should not set an</span><br><span style="color: hsl(120, 100%, 40%);">+error message as this would block later error messages. If NULL is</span><br><span style="color: hsl(120, 100%, 40%);">+received for a non-optional string we should set has_error. Set</span><br><span style="color: hsl(120, 100%, 40%);">+has_error for UTF-8 errors to ensure optional strings with UTF-8</span><br><span style="color: hsl(120, 100%, 40%);">+errors are not replaced with json_null(). Use 'purpose' argument in</span><br><span style="color: hsl(120, 100%, 40%);">+NULL error messages of read_string.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Add error handling and tests for invalid formats where '+', '#', or '%'</span><br><span style="color: hsl(120, 100%, 40%);">+is used on an optional string 's?' or 's*'.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Fix NULL string error messages to use 'purpose'.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Refactor skipping of '*' token, this is now handled by read_string and</span><br><span style="color: hsl(120, 100%, 40%);">+pack_object_inter. This allows invalid format strings such as 's*#' and</span><br><span style="color: hsl(120, 100%, 40%);">+'s*+' to produce error messages.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Fixes #437</span><br><span style="color: hsl(120, 100%, 40%);">+---</span><br><span style="color: hsl(120, 100%, 40%);">+ src/pack_unpack.c | 74 +++++++++++++++++++++++--------------</span><br><span style="color: hsl(120, 100%, 40%);">+ test/suites/api/test_pack.c | 49 ++++++++++++++++++++++--</span><br><span style="color: hsl(120, 100%, 40%);">+ 2 files changed, 93 insertions(+), 30 deletions(-)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/src/pack_unpack.c b/src/pack_unpack.c</span><br><span style="color: hsl(120, 100%, 40%);">+index b842772..fc98df4 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/src/pack_unpack.c</span><br><span>++++ b/src/pack_unpack.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -130,7 +130,7 @@ static json_t *pack(scanner_t *s, va_list *ap);</span><br><span style="color: hsl(120, 100%, 40%);">+ /* ours will be set to 1 if jsonp_free() must be called for the result</span><br><span style="color: hsl(120, 100%, 40%);">+ afterwards */</span><br><span style="color: hsl(120, 100%, 40%);">+ static char *read_string(scanner_t *s, va_list *ap,</span><br><span style="color: hsl(120, 100%, 40%);">+- const char *purpose, size_t *out_len, int *ours)</span><br><span style="color: hsl(120, 100%, 40%);">++ const char *purpose, size_t *out_len, int *ours, int optional)</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ char t;</span><br><span style="color: hsl(120, 100%, 40%);">+ strbuffer_t strbuff;</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -147,7 +147,10 @@ static char *read_string(scanner_t *s, va_list *ap,</span><br><span style="color: hsl(120, 100%, 40%);">+ str = va_arg(*ap, const char *);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ if(!str) {</span><br><span style="color: hsl(120, 100%, 40%);">+- set_error(s, "<args>", json_error_null_value, "NULL string argument");</span><br><span style="color: hsl(120, 100%, 40%);">++ if (!optional) {</span><br><span style="color: hsl(120, 100%, 40%);">++ set_error(s, "<args>", json_error_null_value, "NULL %s", purpose);</span><br><span style="color: hsl(120, 100%, 40%);">++ s->has_error = 1;</span><br><span style="color: hsl(120, 100%, 40%);">++ }</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+@@ -155,11 +158,17 @@ static char *read_string(scanner_t *s, va_list *ap,</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ if(!utf8_check_string(str, length)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ set_error(s, "<args>", json_error_invalid_utf8, "Invalid UTF-8 %s", purpose);</span><br><span style="color: hsl(120, 100%, 40%);">++ s->has_error = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ *out_len = length;</span><br><span style="color: hsl(120, 100%, 40%);">+ return (char *)str;</span><br><span style="color: hsl(120, 100%, 40%);">++ } else if (optional) {</span><br><span style="color: hsl(120, 100%, 40%);">++ set_error(s, "<format>", json_error_invalid_format, "Cannot use '%c' on optional strings", t);</span><br><span style="color: hsl(120, 100%, 40%);">++ s->has_error = 1;</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ if(strbuffer_init(&strbuff)) {</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -170,7 +179,7 @@ static char *read_string(scanner_t *s, va_list *ap,</span><br><span style="color: hsl(120, 100%, 40%);">+ while(1) {</span><br><span style="color: hsl(120, 100%, 40%);">+ str = va_arg(*ap, const char *);</span><br><span style="color: hsl(120, 100%, 40%);">+ if(!str) {</span><br><span style="color: hsl(120, 100%, 40%);">+- set_error(s, "<args>", json_error_null_value, "NULL string argument");</span><br><span style="color: hsl(120, 100%, 40%);">++ set_error(s, "<args>", json_error_null_value, "NULL %s", purpose);</span><br><span style="color: hsl(120, 100%, 40%);">+ s->has_error = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+@@ -226,6 +235,7 @@ static json_t *pack_object(scanner_t *s, va_list *ap)</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t len;</span><br><span style="color: hsl(120, 100%, 40%);">+ int ours;</span><br><span style="color: hsl(120, 100%, 40%);">+ json_t *value;</span><br><span style="color: hsl(120, 100%, 40%);">++ char valueOptional;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ if(!token(s)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ set_error(s, "<format>", json_error_invalid_format, "Unexpected end of format string");</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -237,20 +247,21 @@ static json_t *pack_object(scanner_t *s, va_list *ap)</span><br><span style="color: hsl(120, 100%, 40%);">+ goto error;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+- key = read_string(s, ap, "object key", &len, &ours);</span><br><span style="color: hsl(120, 100%, 40%);">+- if (!key)</span><br><span style="color: hsl(120, 100%, 40%);">+- s->has_error = 1;</span><br><span style="color: hsl(120, 100%, 40%);">++ key = read_string(s, ap, "object key", &len, &ours, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ next_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++ next_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">++ valueOptional = token(s);</span><br><span style="color: hsl(120, 100%, 40%);">++ prev_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ value = pack(s, ap);</span><br><span style="color: hsl(120, 100%, 40%);">+ if(!value) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if(ours)</span><br><span style="color: hsl(120, 100%, 40%);">+ jsonp_free(key);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+- if(strchr("soO", token(s)) && s->next_token.token == '*') {</span><br><span style="color: hsl(120, 100%, 40%);">+- next_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+- } else {</span><br><span style="color: hsl(120, 100%, 40%);">++ if(valueOptional != '*') {</span><br><span style="color: hsl(120, 100%, 40%);">++ set_error(s, "<args>", json_error_null_value, "NULL object value\n");</span><br><span style="color: hsl(120, 100%, 40%);">+ s->has_error = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+@@ -269,8 +280,6 @@ static json_t *pack_object(scanner_t *s, va_list *ap)</span><br><span style="color: hsl(120, 100%, 40%);">+ if(ours)</span><br><span style="color: hsl(120, 100%, 40%);">+ jsonp_free(key);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+- if(strchr("soO", token(s)) && s->next_token.token == '*')</span><br><span style="color: hsl(120, 100%, 40%);">+- next_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+ next_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+@@ -289,6 +298,7 @@ static json_t *pack_array(scanner_t *s, va_list *ap)</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ while(token(s) != ']') {</span><br><span style="color: hsl(120, 100%, 40%);">+ json_t *value;</span><br><span style="color: hsl(120, 100%, 40%);">++ char valueOptional;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ if(!token(s)) {</span><br><span style="color: hsl(120, 100%, 40%);">+ set_error(s, "<format>", json_error_invalid_format, "Unexpected end of format string");</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -296,11 +306,13 @@ static json_t *pack_array(scanner_t *s, va_list *ap)</span><br><span style="color: hsl(120, 100%, 40%);">+ goto error;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++ next_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">++ valueOptional = token(s);</span><br><span style="color: hsl(120, 100%, 40%);">++ prev_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ value = pack(s, ap);</span><br><span style="color: hsl(120, 100%, 40%);">+ if(!value) {</span><br><span style="color: hsl(120, 100%, 40%);">+- if(strchr("soO", token(s)) && s->next_token.token == '*') {</span><br><span style="color: hsl(120, 100%, 40%);">+- next_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+- } else {</span><br><span style="color: hsl(120, 100%, 40%);">++ if(valueOptional != '*') {</span><br><span style="color: hsl(120, 100%, 40%);">+ s->has_error = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+@@ -316,8 +328,6 @@ static json_t *pack_array(scanner_t *s, va_list *ap)</span><br><span style="color: hsl(120, 100%, 40%);">+ s->has_error = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+- if(strchr("soO", token(s)) && s->next_token.token == '*')</span><br><span style="color: hsl(120, 100%, 40%);">+- next_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+ next_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+@@ -332,23 +342,33 @@ error:</span><br><span style="color: hsl(120, 100%, 40%);">+ static json_t *pack_string(scanner_t *s, va_list *ap)</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ char *str;</span><br><span style="color: hsl(120, 100%, 40%);">++ char t;</span><br><span style="color: hsl(120, 100%, 40%);">+ size_t len;</span><br><span style="color: hsl(120, 100%, 40%);">+ int ours;</span><br><span style="color: hsl(120, 100%, 40%);">+- int nullable;</span><br><span style="color: hsl(120, 100%, 40%);">++ int optional;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ next_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+- nullable = token(s) == '?';</span><br><span style="color: hsl(120, 100%, 40%);">+- if (!nullable)</span><br><span style="color: hsl(120, 100%, 40%);">++ t = token(s);</span><br><span style="color: hsl(120, 100%, 40%);">++ optional = t == '?' || t == '*';</span><br><span style="color: hsl(120, 100%, 40%);">++ if (!optional)</span><br><span style="color: hsl(120, 100%, 40%);">+ prev_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+- str = read_string(s, ap, "string", &len, &ours);</span><br><span style="color: hsl(120, 100%, 40%);">+- if (!str) {</span><br><span style="color: hsl(120, 100%, 40%);">+- return nullable ? json_null() : NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+- } else if (ours) {</span><br><span style="color: hsl(120, 100%, 40%);">+- return jsonp_stringn_nocheck_own(str, len);</span><br><span style="color: hsl(120, 100%, 40%);">+- } else {</span><br><span style="color: hsl(120, 100%, 40%);">+- return json_stringn_nocheck(str, len);</span><br><span style="color: hsl(120, 100%, 40%);">++ str = read_string(s, ap, "string", &len, &ours, optional);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ if (!str)</span><br><span style="color: hsl(120, 100%, 40%);">++ return t == '?' && !s->has_error ? json_null() : NULL;</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ if (s->has_error) {</span><br><span style="color: hsl(120, 100%, 40%);">++ if (!ours)</span><br><span style="color: hsl(120, 100%, 40%);">++ jsonp_free(str);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ if (ours)</span><br><span style="color: hsl(120, 100%, 40%);">++ return jsonp_stringn_nocheck_own(str, len);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ return json_stringn_nocheck(str, len);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ static json_t *pack_object_inter(scanner_t *s, va_list *ap, int need_incref)</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -359,7 +379,7 @@ static json_t *pack_object_inter(scanner_t *s, va_list *ap, int need_incref)</span><br><span style="color: hsl(120, 100%, 40%);">+ next_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+ ntoken = token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+- if (ntoken != '?')</span><br><span style="color: hsl(120, 100%, 40%);">++ if (ntoken != '?' && ntoken != '*')</span><br><span style="color: hsl(120, 100%, 40%);">+ prev_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ json = va_arg(*ap, json_t *);</span><br><span style="color: hsl(120, 100%, 40%);">+-- </span><br><span style="color: hsl(120, 100%, 40%);">+2.17.1</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>diff --git a/third-party/jansson/patches/0030-More-work-on-json_pack-error-reporting.patch b/third-party/jansson/patches/0030-More-work-on-json_pack-error-reporting.patch</span><br><span>new file mode 100644</span><br><span>index 0000000..debb2f5</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/jansson/patches/0030-More-work-on-json_pack-error-reporting.patch</span><br><span>@@ -0,0 +1,100 @@</span><br><span style="color: hsl(120, 100%, 40%);">+From 8d659113d53d7ef60eae6a6e2c5b0ecfc89fc74b Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(120, 100%, 40%);">+From: Corey Farrell <git@cfware.com></span><br><span style="color: hsl(120, 100%, 40%);">+Date: Tue, 25 Sep 2018 17:34:25 -0400</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: [PATCH 30/30] More work on json_pack error reporting.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Test updates have been removed for easier merging for bundled build.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+* Remove errant line-feed from pack_object error message.</span><br><span style="color: hsl(120, 100%, 40%);">+* Correct error message in pack_object_inter.</span><br><span style="color: hsl(120, 100%, 40%);">+* Create pack_integer / pack_real to get the correct error messages on</span><br><span style="color: hsl(120, 100%, 40%);">+ failure when packing numeric values.</span><br><span style="color: hsl(120, 100%, 40%);">+* Add tests for packing NAN and infinity directly, in an array and as</span><br><span style="color: hsl(120, 100%, 40%);">+ an object value.</span><br><span style="color: hsl(120, 100%, 40%);">+---</span><br><span style="color: hsl(120, 100%, 40%);">+ src/pack_unpack.c | 46 +++++++++++++++++++++++++++----</span><br><span style="color: hsl(120, 100%, 40%);">+ test/suites/api/test_pack.c | 54 +++++++++++++++++++++++++++++++++++--</span><br><span style="color: hsl(120, 100%, 40%);">+ 2 files changed, 93 insertions(+), 7 deletions(-)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/src/pack_unpack.c b/src/pack_unpack.c</span><br><span style="color: hsl(120, 100%, 40%);">+index fc98df4..ec04bc3 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/src/pack_unpack.c</span><br><span>++++ b/src/pack_unpack.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -261,7 +261,7 @@ static json_t *pack_object(scanner_t *s, va_list *ap)</span><br><span style="color: hsl(120, 100%, 40%);">+ jsonp_free(key);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ if(valueOptional != '*') {</span><br><span style="color: hsl(120, 100%, 40%);">+- set_error(s, "<args>", json_error_null_value, "NULL object value\n");</span><br><span style="color: hsl(120, 100%, 40%);">++ set_error(s, "<args>", json_error_null_value, "NULL object value");</span><br><span style="color: hsl(120, 100%, 40%);">+ s->has_error = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+@@ -396,11 +396,47 @@ static json_t *pack_object_inter(scanner_t *s, va_list *ap, int need_incref)</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+- set_error(s, "<args>", json_error_null_value, "NULL object key");</span><br><span style="color: hsl(120, 100%, 40%);">++ set_error(s, "<args>", json_error_null_value, "NULL object");</span><br><span style="color: hsl(120, 100%, 40%);">+ s->has_error = 1;</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++static json_t *pack_integer(scanner_t *s, json_int_t value)</span><br><span style="color: hsl(120, 100%, 40%);">++{</span><br><span style="color: hsl(120, 100%, 40%);">++ json_t *json = json_integer(value);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ if (!json) {</span><br><span style="color: hsl(120, 100%, 40%);">++ set_error(s, "<internal>", json_error_out_of_memory, "Out of memory");</span><br><span style="color: hsl(120, 100%, 40%);">++ s->has_error = 1;</span><br><span style="color: hsl(120, 100%, 40%);">++ }</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ return json;</span><br><span style="color: hsl(120, 100%, 40%);">++}</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++static json_t *pack_real(scanner_t *s, double value)</span><br><span style="color: hsl(120, 100%, 40%);">++{</span><br><span style="color: hsl(120, 100%, 40%);">++ /* Allocate without setting value so we can identify OOM error. */</span><br><span style="color: hsl(120, 100%, 40%);">++ json_t *json = json_real(0.0);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ if (!json) {</span><br><span style="color: hsl(120, 100%, 40%);">++ set_error(s, "<internal>", json_error_out_of_memory, "Out of memory");</span><br><span style="color: hsl(120, 100%, 40%);">++ s->has_error = 1;</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">++ }</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ if (json_real_set(json, value)) {</span><br><span style="color: hsl(120, 100%, 40%);">++ json_decref(json);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ set_error(s, "<args>", json_error_numeric_overflow, "Invalid floating point value");</span><br><span style="color: hsl(120, 100%, 40%);">++ s->has_error = 1;</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">++ }</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ return json;</span><br><span style="color: hsl(120, 100%, 40%);">++}</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ static json_t *pack(scanner_t *s, va_list *ap)</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ switch(token(s)) {</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -420,13 +456,13 @@ static json_t *pack(scanner_t *s, va_list *ap)</span><br><span style="color: hsl(120, 100%, 40%);">+ return va_arg(*ap, int) ? json_true() : json_false();</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ case 'i': /* integer from int */</span><br><span style="color: hsl(120, 100%, 40%);">+- return json_integer(va_arg(*ap, int));</span><br><span style="color: hsl(120, 100%, 40%);">++ return pack_integer(s, va_arg(*ap, int));</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ case 'I': /* integer from json_int_t */</span><br><span style="color: hsl(120, 100%, 40%);">+- return json_integer(va_arg(*ap, json_int_t));</span><br><span style="color: hsl(120, 100%, 40%);">++ return pack_integer(s, va_arg(*ap, json_int_t));</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ case 'f': /* real */</span><br><span style="color: hsl(120, 100%, 40%);">+- return json_real(va_arg(*ap, double));</span><br><span style="color: hsl(120, 100%, 40%);">++ return pack_real(s, va_arg(*ap, double));</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ case 'O': /* a json_t object; increments refcount */</span><br><span style="color: hsl(120, 100%, 40%);">+ return pack_object_inter(s, ap, 1);</span><br><span style="color: hsl(120, 100%, 40%);">+-- </span><br><span style="color: hsl(120, 100%, 40%);">+2.17.1</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10322">change 10322</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/10322"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I045e420d5e73e60639079246e810da6ae21ae22b </div>
<div style="display:none"> Gerrit-Change-Number: 10322 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 (1000185) </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com> </div>