Skip to content

Commit

Permalink
Use ImagingError_MemoryError NULL return value
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Dec 20, 2020
1 parent 75542fe commit b7fb39f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
6 changes: 2 additions & 4 deletions src/_imaging.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/encode.c
Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions src/path.c
Expand Up @@ -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) {
Expand Down

0 comments on commit b7fb39f

Please sign in to comment.