Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lz4/frame/_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ destroy_compression_context (PyObject * py_context)
/* Compatibility with 2.6 via capsulethunk. */
struct compression_context *context = py_context;
#endif
if (context == NULL)
return;
Py_BEGIN_ALLOW_THREADS
LZ4F_freeCompressionContext (context->context);
Py_END_ALLOW_THREADS
Expand Down Expand Up @@ -836,6 +838,8 @@ destroy_decompression_context (PyObject * py_context)
/* Compatibility with 2.6 via capsulethunk. */
LZ4F_dctx * context = py_context;
#endif
if (context == NULL)
return;
Py_BEGIN_ALLOW_THREADS
LZ4F_freeDecompressionContext (context);
Py_END_ALLOW_THREADS
Expand All @@ -852,7 +856,6 @@ create_decompression_context (PyObject * Py_UNUSED (self))
if (LZ4F_isError (result))
{
Py_BLOCK_THREADS
LZ4F_freeDecompressionContext (context);
PyErr_Format (PyExc_RuntimeError,
"LZ4F_createDecompressionContext failed with code: %s",
LZ4F_getErrorName (result));
Expand Down Expand Up @@ -913,7 +916,6 @@ reset_decompression_context (PyObject * Py_UNUSED (self), PyObject * args,
result = LZ4F_createDecompressionContext (&context, LZ4F_VERSION);
if (LZ4F_isError (result))
{
LZ4F_freeDecompressionContext (context);
Py_BLOCK_THREADS
PyErr_Format (PyExc_RuntimeError,
"LZ4F_createDecompressionContext failed with code: %s",
Expand All @@ -927,7 +929,7 @@ reset_decompression_context (PyObject * Py_UNUSED (self), PyObject * args,
{
LZ4F_freeDecompressionContext (context);
PyErr_SetString (PyExc_RuntimeError,
"PyCapsule_SetPointer failed with code: %s");
"PyCapsule_SetPointer failed");
return NULL;
}
}
Expand Down
Loading