Skip to content

Commit 2dff768

Browse files
committed
Removes a memory leak on the JSON parser
1 parent 145f2f3 commit 2dff768

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
v3.0.4 - YYYY-MMM-DD (to be released)
22
-------------------------------------
33

4+
- Removes a memory leak on the JSON parser
5+
[@zimmerle]
46
- Enables LMDB on the regression tests.
57
[Issue #2011, #2008 - @WGH-, @mdunc]
68
- Fix: Extra whitespace in some configuration directives causing error

src/request_body_processor/json.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@ bool JSON::processChunk(const char *buf, unsigned int size, std::string *err) {
8787
m_status = yajl_parse(m_handle,
8888
(const unsigned char *)buf, size);
8989
if (m_status != yajl_status_ok) {
90-
const unsigned char *e = yajl_get_error(m_handle, 0,
90+
unsigned char *e = yajl_get_error(m_handle, 0,
9191
(const unsigned char *)buf, size);
9292
/* We need to free the yajl error message later, how to do this? */
9393
err->assign((const char *)e);
94+
yajl_free_error(m_handle, e);
9495
return false;
9596
}
9697

@@ -102,9 +103,10 @@ bool JSON::complete(std::string *err) {
102103
/* Wrap up the parsing process */
103104
m_status = yajl_complete_parse(m_handle);
104105
if (m_status != yajl_status_ok) {
105-
const unsigned char *e = yajl_get_error(m_handle, 0, NULL, 0);
106+
unsigned char *e = yajl_get_error(m_handle, 0, NULL, 0);
106107
/* We need to free the yajl error message later, how to do this? */
107108
err->assign((const char *)e);
109+
yajl_free_error(m_handle, e);
108110
return false;
109111
}
110112

0 commit comments

Comments
 (0)