Use ImagingError_MemoryError NULL return value

This commit is contained in:
Andrew Murray 2020-12-20 12:28:52 +11:00
parent 75542fea6d
commit b7fb39fff8
3 changed files with 5 additions and 10 deletions

View File

@ -2711,8 +2711,7 @@ _font_getmask(ImagingFontObject* self, PyObject* args)
im = ImagingNew(self->bitmap->mode, textwidth(self, text), self->ysize);
if (!im) {
free(text);
ImagingError_MemoryError();
return NULL;
return ImagingError_MemoryError();
}
b = 0;
@ -3933,8 +3932,7 @@ _set_blocks_max(PyObject* self, PyObject* args)
if ( ! ImagingMemorySetBlocksMax(&ImagingDefaultArena, blocks_max)) {
ImagingError_MemoryError();
return NULL;
return ImagingError_MemoryError();
}
Py_INCREF(Py_None);

View File

@ -1005,8 +1005,7 @@ static unsigned int* get_qtables_arrays(PyObject* qtables, int* qtablesLen) {
qarrays = (unsigned int*) malloc(num_tables * DCTSIZE2 * sizeof(unsigned int));
if (!qarrays) {
Py_DECREF(tables);
ImagingError_MemoryError();
return NULL;
return ImagingError_MemoryError();
}
for (i = 0; i < num_tables; i++) {
table = PySequence_Fast_GET_ITEM(tables, i);

View File

@ -53,12 +53,10 @@ alloc_array(Py_ssize_t count)
{
double* xy;
if (count < 0) {
ImagingError_MemoryError();
return NULL;
return ImagingError_MemoryError();
}
if ((unsigned long long)count > (SIZE_MAX / (2 * sizeof(double))) - 1 ) {
ImagingError_MemoryError();
return NULL;
return ImagingError_MemoryError();
}
xy = malloc(2 * count * sizeof(double) + 1);
if (!xy) {