From 48c02bf339cbf056d9f202573d57a3d0a95deef2 Mon Sep 17 00:00:00 2001 From: Philippe Lague-Morin Date: Fri, 19 Aug 2011 00:21:54 -0300 Subject: Edited src/yajl_tree.c via GitHub --- src/yajl_tree.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/yajl_tree.c b/src/yajl_tree.c index 111e49f..de76e54 100644 --- a/src/yajl_tree.c +++ b/src/yajl_tree.c @@ -421,6 +421,7 @@ yajl_val yajl_tree_parse (const char *input, yajl_handle handle; yajl_status status; + char * internal_err_str; context_t ctx = { NULL, NULL, NULL, 0 }; ctx.errbuf = error_buffer; @@ -438,11 +439,11 @@ yajl_val yajl_tree_parse (const char *input, status = yajl_complete_parse (handle); if (status != yajl_status_ok) { if (error_buffer != NULL && error_buffer_size > 0) { - snprintf( - error_buffer, error_buffer_size, "%s", - (char *) yajl_get_error(handle, 1, - (const unsigned char *) input, - strlen(input))); + internal_err_str = (char *) yajl_get_error(handle, 1, + (const unsigned char *) input, + strlen(input)); + snprintf(error_buffer, error_buffer_size, "%s", internal_err_str); + YA_FREE(&(handle->alloc), internal_err_str); } yajl_free (handle); return NULL; -- cgit v1.2.1 From a3b992b9f3dd4147ac1ed2789978ca3056b4f714 Mon Sep 17 00:00:00 2001 From: 7AC Date: Tue, 14 Jun 2011 15:29:01 +0800 Subject: added errno resetting before setting/checking it in yajl_do_parse() --- src/yajl_parser.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/yajl_parser.c b/src/yajl_parser.c index 3903b38..2cf8a07 100644 --- a/src/yajl_parser.c +++ b/src/yajl_parser.c @@ -279,6 +279,7 @@ yajl_do_parse(yajl_handle hand, const unsigned char * jsonText, hand->ctx,(const char *) buf, bufLen)); } else if (hand->callbacks->yajl_integer) { long long int i = 0; + errno = 0; i = yajl_parse_integer(buf, bufLen); if ((i == LLONG_MIN || i == LLONG_MAX) && errno == ERANGE) @@ -306,6 +307,7 @@ yajl_do_parse(yajl_handle hand, const unsigned char * jsonText, yajl_buf_clear(hand->decodeBuf); yajl_buf_append(hand->decodeBuf, buf, bufLen); buf = yajl_buf_data(hand->decodeBuf); + errno = 0; d = strtod((char *) buf, NULL); if ((d == HUGE_VAL || d == -HUGE_VAL) && errno == ERANGE) -- cgit v1.2.1