summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLloyd Hilaiel <lloyd@hilaiel.com>2011-12-19 15:06:16 -0800
committerLloyd Hilaiel <lloyd@hilaiel.com>2011-12-19 15:06:16 -0800
commit150333b2791527fc8a18fe078c9c73945aed47b5 (patch)
tree4c31c399405bce69f93b0b8e8c4987438c381e22
parent83494d6cb0fa1891054d57554ae542169d26b9fb (diff)
parenta3b992b9f3dd4147ac1ed2789978ca3056b4f714 (diff)
downloadyajl-150333b2791527fc8a18fe078c9c73945aed47b5.tar.gz
Merge pull request #57 from plaguemorin/master
Fixed memory leak
-rw-r--r--src/yajl_tree.c11
1 files 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;