]> granicus.if.org Git - json-c/commitdiff
Fix broken build by using ADVANCE_CHAR macro return.
authorWilliam Dignazio <slackwill@csh.rit.edu>
Thu, 7 Mar 2013 01:18:14 +0000 (20:18 -0500)
committerWilliam Dignazio <slackwill@csh.rit.edu>
Thu, 7 Mar 2013 01:18:14 +0000 (20:18 -0500)
We forget to check or use the return value of the ADVANCE_CHAR macro,
and upon compilation an error is thrown because of its lack of use. This
patch checks to see if the macro was successful, and if not replaces the
offending character with a replacement.

json_tokener.c

index afb7bb2b9198a4ffacfa7e7b25c0f43f28835c2b..6d50bc2333b0622303c300c0013bbec797ffad7e 100644 (file)
@@ -507,9 +507,13 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
                       (str[1] == '\\') &&
                       (str[2] == 'u'))
                   {
-                   ADVANCE_CHAR(str, tok);
-                   ADVANCE_CHAR(str, tok);
-
+                /* Advance through the 16 bit surrogate, and move on to the
+                 * next sequence. The next step is to process the following
+                 * characters.
+                 */
+                   if( !ADVANCE_CHAR(str, tok) || !ADVANCE_CHAR(str, tok) ) {
+                    printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3);
+                }
                     /* Advance to the first char of the next sequence and
                      * continue processing with the next sequence.
                      */