Revision: 7245
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7245&view=rev
Author:   mdboom
Date:     2009-07-01 19:55:17 +0000 (Wed, 01 Jul 2009)

Log Message:
-----------
Fix out-of-memory errors leading to segfaults

Modified Paths:
--------------
    branches/v0_98_5_maint/src/_path.cpp
    branches/v0_98_5_maint/src/_png.cpp

Modified: branches/v0_98_5_maint/src/_path.cpp
===================================================================
--- branches/v0_98_5_maint/src/_path.cpp        2009-06-29 15:11:00 UTC (rev 
7244)
+++ branches/v0_98_5_maint/src/_path.cpp        2009-07-01 19:55:17 UTC (rev 
7245)
@@ -882,6 +882,9 @@
             size_t size = p->size();
             dims[0] = p->size();
             PyArrayObject* pyarray = (PyArrayObject*)PyArray_SimpleNew(2, 
dims, PyArray_DOUBLE);
+            if (pyarray == NULL) {
+                throw Py::MemoryError("Could not allocate result array");
+            }
             for (size_t i = 0; i < size; ++i)
             {
                 ((double *)pyarray->data)[2*i]  = (*p)[i].x;
@@ -951,6 +954,9 @@
 
         result = (PyArrayObject*)PyArray_SimpleNew
           (PyArray_NDIM(vertices), PyArray_DIMS(vertices), PyArray_DOUBLE);
+        if (result == NULL) {
+            throw Py::MemoryError("Could not allocate memory for path");
+        }
         if (PyArray_NDIM(vertices) == 2)
         {
             size_t n = PyArray_DIM(vertices, 0);

Modified: branches/v0_98_5_maint/src/_png.cpp
===================================================================
--- branches/v0_98_5_maint/src/_png.cpp 2009-06-29 15:11:00 UTC (rev 7244)
+++ branches/v0_98_5_maint/src/_png.cpp 2009-07-01 19:55:17 UTC (rev 7245)
@@ -266,6 +266,10 @@
   double max_value = (1 << ((bit_depth < 8) ? 8 : bit_depth)) - 1;
   PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew(num_dims, dimensions, 
PyArray_FLOAT);
 
+  if (A == NULL) {
+    throw Py::MemoryError("Could not allocate image array");
+  }
+
   for (png_uint_32 y = 0; y < height; y++) {
     png_byte* row = row_pointers[y];
        for (png_uint_32 x = 0; x < width; x++) {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to