Permalink
Browse files

Merge pull request #57 from plaguemorin/master

Fixed memory leak
  • Loading branch information...
2 parents 83494d6 + a3b992b commit 150333b2791527fc8a18fe078c9c73945aed47b5 @lloyd committed Dec 19, 2011
Showing with 6 additions and 5 deletions.
  1. +6 −5 src/yajl_tree.c
View
@@ -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;

0 comments on commit 150333b

Please sign in to comment.