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

Commit

Permalink
Browse files Browse the repository at this point in the history
missed the pybuffer decref in Decoder.decode
  • Loading branch information
teepark committed Apr 27, 2011
1 parent e150d09 commit 4aadc2f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions decoder.c
Expand Up @@ -282,7 +282,7 @@ PyObject *py_yajldecoder_decode(PYARGS)
_YajlDecoder *decoder = (_YajlDecoder *)(self); _YajlDecoder *decoder = (_YajlDecoder *)(self);
char *buffer = NULL; char *buffer = NULL;
PyObject *pybuffer = NULL; PyObject *pybuffer = NULL;
PyObject *alternate = NULL; PyObject *result = NULL;
Py_ssize_t buflen = 0; Py_ssize_t buflen = 0;


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


if (PyUnicode_Check(pybuffer)) { if (PyUnicode_Check(pybuffer)) {
if (!(alternate = PyUnicode_AsUTF8String(pybuffer))) { if (!(result = PyUnicode_AsUTF8String(pybuffer))) {
Py_DECREF(pybuffer); Py_DECREF(pybuffer);
return NULL; return NULL;
} }
Py_DECREF(pybuffer); Py_DECREF(pybuffer);
pybuffer = alternate; pybuffer = result;
result = NULL;
} }


if (PyString_Check(pybuffer)) { if (PyString_Check(pybuffer)) {
Expand All @@ -317,7 +318,10 @@ PyObject *py_yajldecoder_decode(PYARGS)
PyUnicode_FromString("Cannot parse an empty buffer")); PyUnicode_FromString("Cannot parse an empty buffer"));
return NULL; return NULL;
} }
return _internal_decode(decoder, buffer, (unsigned int)buflen);
result = _internal_decode(decoder, buffer, (unsigned int)buflen);
Py_DECREF(pybuffer);
return result;
} }


int yajldecoder_init(PYARGS) int yajldecoder_init(PYARGS)
Expand Down

0 comments on commit 4aadc2f

Please sign in to comment.