Skip to content
This repository was archived by the owner on Mar 8, 2018. It is now read-only.

Commit a652ad0

Browse files
committed
Fix memory leaks in ProcessObject.
1 parent 110f2eb commit a652ad0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

encoder.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ static yajl_gen_status ProcessObject(_YajlEncoder *self, PyObject *object)
142142
}
143143
}
144144
buffer[offset] = '\0';
145-
return yajl_gen_raw_string(handle, (const unsigned char *)(buffer), (unsigned int)(offset));
145+
status = yajl_gen_raw_string(handle, (const unsigned char *)(buffer), (unsigned int)(offset));
146+
free(buffer);
147+
return status;
146148
}
147149
#ifdef IS_PYTHON3
148150
if (PyBytes_Check(object)) {
@@ -238,6 +240,9 @@ static yajl_gen_status ProcessObject(_YajlEncoder *self, PyObject *object)
238240
}
239241

240242
status = ProcessObject(self, newKey);
243+
if (key != newKey) {
244+
Py_XDECREF(newKey);
245+
}
241246
if (status == yajl_gen_in_error_state) return status;
242247
if (status == yajl_max_depth_exceeded) goto exit;
243248

0 commit comments

Comments
 (0)