diff --git a/src/libCom/yajl/yajl.c b/src/libCom/yajl/yajl.c index 54dffd11e..6c4977598 100644 --- a/src/libCom/yajl/yajl.c +++ b/src/libCom/yajl/yajl.c @@ -63,6 +63,9 @@ yajl_alloc(const yajl_callbacks * callbacks, } hand = (yajl_handle) YA_MALLOC(afs, sizeof(struct yajl_handle_t)); + if (hand == NULL) { + return NULL; + } /* copy in pointers to allocation routines */ memcpy((void *) &(hand->alloc), (void *) afs, sizeof(yajl_alloc_funcs)); @@ -127,6 +130,9 @@ yajl_parse(yajl_handle hand, const unsigned char * jsonText, hand->flags & yajl_allow_comments, !(hand->flags & yajl_dont_validate_strings)); } + if (hand->lexer == NULL) { + return yajl_status_error; + } status = yajl_do_parse(hand, jsonText, jsonTextLen); return status; diff --git a/src/libCom/yajl/yajl_buf.c b/src/libCom/yajl/yajl_buf.c index 4b14d9acd..0f9c28046 100644 --- a/src/libCom/yajl/yajl_buf.c +++ b/src/libCom/yajl/yajl_buf.c @@ -57,6 +57,10 @@ void yajl_buf_ensure_available(yajl_buf buf, size_t want) yajl_buf yajl_buf_alloc(yajl_alloc_funcs * alloc) { yajl_buf b = YA_MALLOC(alloc, sizeof(struct yajl_buf_t)); + if (b == NULL) { + return NULL; + } + memset((void *) b, 0, sizeof(struct yajl_buf_t)); b->alloc = alloc; return b; diff --git a/src/libCom/yajl/yajl_lex.c b/src/libCom/yajl/yajl_lex.c index 80d713641..0159cfa55 100644 --- a/src/libCom/yajl/yajl_lex.c +++ b/src/libCom/yajl/yajl_lex.c @@ -106,6 +106,10 @@ yajl_lex_alloc(yajl_alloc_funcs * alloc, unsigned int allowComments, unsigned int validateUTF8) { yajl_lexer lxr = (yajl_lexer) YA_MALLOC(alloc, sizeof(struct yajl_lexer_t)); + if (lxr == NULL) { + return NULL; + } + memset((void *) lxr, 0, sizeof(struct yajl_lexer_t)); lxr->buf = yajl_buf_alloc(alloc); lxr->allowComments = allowComments; diff --git a/src/libCom/yajl/yajl_parser.c b/src/libCom/yajl/yajl_parser.c index 867108418..b1d75fe55 100644 --- a/src/libCom/yajl/yajl_parser.c +++ b/src/libCom/yajl/yajl_parser.c @@ -34,7 +34,7 @@ /* same semantics as strtol */ long long -yajl_parse_integer(const unsigned char *number, unsigned int length) +yajl_parse_integer(const unsigned char *number, size_t length) { long long ret = 0; long sign = 1; diff --git a/src/libCom/yajl/yajl_parser.h b/src/libCom/yajl/yajl_parser.h index 4b4b9352a..bd5a74dfd 100644 --- a/src/libCom/yajl/yajl_parser.h +++ b/src/libCom/yajl/yajl_parser.h @@ -72,7 +72,7 @@ yajl_render_error_string(yajl_handle hand, const unsigned char * jsonText, /* A little built in integer parsing routine with the same semantics as strtol * that's unaffected by LOCALE. */ long long -yajl_parse_integer(const unsigned char *number, unsigned int length); +yajl_parse_integer(const unsigned char *number, size_t length); #endif