File tree 2 files changed +10
-0
lines changed 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -882,6 +882,9 @@ Py::Object _path_module::clip_path_to_rect(const Py::Tuple &args)
882
882
size_t size = p->size ();
883
883
dims[0 ] = p->size ();
884
884
PyArrayObject* pyarray = (PyArrayObject*)PyArray_SimpleNew (2 , dims, PyArray_DOUBLE);
885
+ if (pyarray == NULL ) {
886
+ throw Py::MemoryError (" Could not allocate result array" );
887
+ }
885
888
for (size_t i = 0 ; i < size; ++i)
886
889
{
887
890
((double *)pyarray->data )[2 *i] = (*p)[i].x ;
@@ -951,6 +954,9 @@ Py::Object _path_module::affine_transform(const Py::Tuple& args)
951
954
952
955
result = (PyArrayObject*)PyArray_SimpleNew
953
956
(PyArray_NDIM (vertices), PyArray_DIMS (vertices), PyArray_DOUBLE);
957
+ if (result == NULL ) {
958
+ throw Py::MemoryError (" Could not allocate memory for path" );
959
+ }
954
960
if (PyArray_NDIM (vertices) == 2 )
955
961
{
956
962
size_t n = PyArray_DIM (vertices, 0 );
Original file line number Diff line number Diff line change @@ -266,6 +266,10 @@ _png_module::read_png(const Py::Tuple& args) {
266
266
double max_value = (1 << ((bit_depth < 8 ) ? 8 : bit_depth)) - 1 ;
267
267
PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew (num_dims, dimensions, PyArray_FLOAT);
268
268
269
+ if (A == NULL ) {
270
+ throw Py::MemoryError (" Could not allocate image array" );
271
+ }
272
+
269
273
for (png_uint_32 y = 0 ; y < height; y++) {
270
274
png_byte* row = row_pointers[y];
271
275
for (png_uint_32 x = 0 ; x < width; x++) {
You can’t perform that action at this time.
0 commit comments