Removes a memory leak on the JSON parser

This commit is contained in:
Felipe Zimmerle 2019-02-11 10:17:02 -03:00
parent 145f2f35b7
commit 2dff768262
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277
2 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,8 @@
v3.0.4 - YYYY-MMM-DD (to be released)
-------------------------------------
- Removes a memory leak on the JSON parser
[@zimmerle]
- Enables LMDB on the regression tests.
[Issue #2011, #2008 - @WGH-, @mdunc]
- Fix: Extra whitespace in some configuration directives causing error

View File

@ -87,10 +87,11 @@ bool JSON::processChunk(const char *buf, unsigned int size, std::string *err) {
m_status = yajl_parse(m_handle,
(const unsigned char *)buf, size);
if (m_status != yajl_status_ok) {
const unsigned char *e = yajl_get_error(m_handle, 0,
unsigned char *e = yajl_get_error(m_handle, 0,
(const unsigned char *)buf, size);
/* We need to free the yajl error message later, how to do this? */
err->assign((const char *)e);
yajl_free_error(m_handle, e);
return false;
}
@ -102,9 +103,10 @@ bool JSON::complete(std::string *err) {
/* Wrap up the parsing process */
m_status = yajl_complete_parse(m_handle);
if (m_status != yajl_status_ok) {
const unsigned char *e = yajl_get_error(m_handle, 0, NULL, 0);
unsigned char *e = yajl_get_error(m_handle, 0, NULL, 0);
/* We need to free the yajl error message later, how to do this? */
err->assign((const char *)e);
yajl_free_error(m_handle, e);
return false;
}