Skip to content

Commit 6b548e8

Browse files
Merge pull request python#28 from python-lz4/segfault_fix
Grab GIL when realloc'ing in decompress
2 parents f5deddc + 6425cc9 commit 6b548e8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lz4/frame/_frame.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,16 +787,17 @@ decompress (PyObject * Py_UNUSED (self), PyObject * args, PyObject * keywds)
787787
to estimate the new size of the destination buffer. */
788788
char * destination_buffer_new;
789789
destination_size += 3 * result;
790+
Py_BLOCK_THREADS
790791
destination_buffer_new = PyMem_Realloc(destination_buffer, destination_size);
791792
if (!destination_buffer_new)
792793
{
793794
LZ4F_freeDecompressionContext (context);
794-
Py_BLOCK_THREADS
795795
PyErr_SetString (PyExc_RuntimeError,
796796
"Failed to increase destination buffer size");
797797
PyMem_Free (destination_buffer);
798798
return NULL;
799799
}
800+
Py_UNBLOCK_THREADS
800801
destination_buffer = destination_buffer_new;
801802
}
802803
/* Data still remaining to be decompressed, so increment the source and

0 commit comments

Comments
 (0)