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

Commit 4aadc2f

Browse files
committed
missed the pybuffer decref in Decoder.decode
1 parent e150d09 commit 4aadc2f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

decoder.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ PyObject *py_yajldecoder_decode(PYARGS)
282282
_YajlDecoder *decoder = (_YajlDecoder *)(self);
283283
char *buffer = NULL;
284284
PyObject *pybuffer = NULL;
285-
PyObject *alternate = NULL;
285+
PyObject *result = NULL;
286286
Py_ssize_t buflen = 0;
287287

288288
if (!PyArg_ParseTuple(args, "O", &pybuffer))
@@ -291,12 +291,13 @@ PyObject *py_yajldecoder_decode(PYARGS)
291291
Py_INCREF(pybuffer);
292292

293293
if (PyUnicode_Check(pybuffer)) {
294-
if (!(alternate = PyUnicode_AsUTF8String(pybuffer))) {
294+
if (!(result = PyUnicode_AsUTF8String(pybuffer))) {
295295
Py_DECREF(pybuffer);
296296
return NULL;
297297
}
298298
Py_DECREF(pybuffer);
299-
pybuffer = alternate;
299+
pybuffer = result;
300+
result = NULL;
300301
}
301302

302303
if (PyString_Check(pybuffer)) {
@@ -317,7 +318,10 @@ PyObject *py_yajldecoder_decode(PYARGS)
317318
PyUnicode_FromString("Cannot parse an empty buffer"));
318319
return NULL;
319320
}
320-
return _internal_decode(decoder, buffer, (unsigned int)buflen);
321+
322+
result = _internal_decode(decoder, buffer, (unsigned int)buflen);
323+
Py_DECREF(pybuffer);
324+
return result;
321325
}
322326

323327
int yajldecoder_init(PYARGS)

0 commit comments

Comments
 (0)