Merge pull request #3219 from DerDakon/invalid-free

Avoid invalid free if out of memory
This commit is contained in:
Alexander Karpinsky 2018-07-22 17:06:35 +03:00 committed by GitHub
commit 90a94e7dae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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 */ /* malloc check ok, max is 2 * 4 * 65**3 = 2197000 */
prepared = (INT16*) malloc(sizeof(INT16) * table_size); prepared = (INT16*) malloc(sizeof(INT16) * table_size);
if ( ! prepared) { if ( ! prepared) {
if (free_table_data)
free(table_data); free(table_data);
return (INT16*) PyErr_NoMemory(); return (INT16*) PyErr_NoMemory();
} }