From 32eddd66f510fb13ef61d4ecab5296bcb771f111 Mon Sep 17 00:00:00 2001 From: William Dignazio Date: Wed, 6 Mar 2013 20:18:14 -0500 Subject: [PATCH] Fix broken build by using ADVANCE_CHAR macro return. 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 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/json_tokener.c b/json_tokener.c index afb7bb2..6d50bc2 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -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. */ -- 2.40.0