avoid invalid free if out of memory

The surrounding code suggests this should only be freed if it was allocated
locally.
This commit is contained in:
Rolf Eike Beer 2018-07-01 12:50:33 +02:00
parent 4407cb6507
commit b565f45d77

View File

@ -778,6 +778,7 @@ _prepare_lut_table(PyObject* table, Py_ssize_t table_size)
/* malloc check ok, max is 2 * 4 * 65**3 = 2197000 */
prepared = (INT16*) malloc(sizeof(INT16) * table_size);
if ( ! prepared) {
if (free_table_data)
free(table_data);
return (INT16*) PyErr_NoMemory();
}