There was an error while loading. Please reload this page.
1 parent f7a31ea commit 9c9feceCopy full SHA for 9c9fece
1 file changed
src/path.c
@@ -343,11 +343,14 @@ path_compact(PyPathObject *self, PyObject *args) {
343
}
344
345
i = self->count - j;
346
- self->count = j;
347
348
/* shrink coordinate array */
349
- /* malloc check ok, self->count is smaller than it was before */
350
- self->xy = realloc(self->xy, 2 * self->count * sizeof(double));
+ double *new_xy = realloc(self->xy, 2 * j * sizeof(double));
+ if (!new_xy) {
+ return ImagingError_MemoryError();
351
+ }
352
+ self->xy = new_xy;
353
+ self->count = j;
354
355
return Py_BuildValue("i", i); /* number of removed vertices */
356
0 commit comments