Skip to content

Commit

Permalink
Merge pull request #2989 from jkseppan/tidyup-ttconv
Browse files Browse the repository at this point in the history
Don't call Py_DECREF on null in _ttconv.cpp
  • Loading branch information
mdboom committed Apr 19, 2014
2 parents 03e60dc + 3dd16b5 commit eb7fd2a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/_ttconv.cpp
Expand Up @@ -11,6 +11,7 @@
#include <Python.h>
#include "ttconv/pprdrv.h"
#include <vector>
#include <cassert>

class PythonExceptionOccurred
{
Expand Down Expand Up @@ -185,14 +186,17 @@ class PythonDictionaryCallback : public TTDictionaryCallback

virtual void add_pair(const char* a, const char* b)
{
assert(a != NULL);
assert(b != NULL);
PyObject* value = PyBytes_FromString(b);
if (value)
if (!value)
{
if (PyDict_SetItemString(_dict, a, value))
{
Py_DECREF(value);
throw PythonExceptionOccurred();
}
throw PythonExceptionOccurred();
}
if (PyDict_SetItemString(_dict, a, value))
{
Py_DECREF(value);
throw PythonExceptionOccurred();
}
Py_DECREF(value);
}
Expand Down

0 comments on commit eb7fd2a

Please sign in to comment.