File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
Expand file tree Collapse file tree 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)
882882 size_t size = p->size ();
883883 dims[0 ] = p->size ();
884884 PyArrayObject* pyarray = (PyArrayObject*)PyArray_SimpleNew (2 , dims, PyArray_DOUBLE);
885+ if (pyarray == NULL ) {
886+ throw Py::MemoryError (" Could not allocate result array" );
887+ }
885888 for (size_t i = 0 ; i < size; ++i)
886889 {
887890 ((double *)pyarray->data )[2 *i] = (*p)[i].x ;
@@ -951,6 +954,9 @@ Py::Object _path_module::affine_transform(const Py::Tuple& args)
951954
952955 result = (PyArrayObject*)PyArray_SimpleNew
953956 (PyArray_NDIM (vertices), PyArray_DIMS (vertices), PyArray_DOUBLE);
957+ if (result == NULL ) {
958+ throw Py::MemoryError (" Could not allocate memory for path" );
959+ }
954960 if (PyArray_NDIM (vertices) == 2 )
955961 {
956962 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) {
266266 double max_value = (1 << ((bit_depth < 8 ) ? 8 : bit_depth)) - 1 ;
267267 PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew (num_dims, dimensions, PyArray_FLOAT);
268268
269+ if (A == NULL ) {
270+ throw Py::MemoryError (" Could not allocate image array" );
271+ }
272+
269273 for (png_uint_32 y = 0 ; y < height; y++) {
270274 png_byte* row = row_pointers[y];
271275 for (png_uint_32 x = 0 ; x < width; x++) {
You can’t perform that action at this time.
0 commit comments