dia r4346 - in trunk: . plug-ins/python



Author: hans
Date: Thu Mar 26 20:33:47 2009
New Revision: 4346
URL: http://svn.gnome.org/viewvc/dia?rev=4346&view=rev

Log:
2009-03-26  Hans Breuer  <hans breuer org>

	* plug-ins/python/pydia-property.c : check for a correct number of
	bezier points before assigning them. So evem a broken PyDia script
	can not crash the core (this way)



Modified:
   trunk/ChangeLog
   trunk/plug-ins/python/pydia-property.c

Modified: trunk/plug-ins/python/pydia-property.c
==============================================================================
--- trunk/plug-ins/python/pydia-property.c	(original)
+++ trunk/plug-ins/python/pydia-property.c	Thu Mar 26 20:33:47 2009
@@ -472,6 +472,7 @@
     BezPoint bpt;
     gboolean is_list = !PyTuple_Check(val);
     int i, len = is_list ? PyList_Size(val) : PyTuple_Size(val);
+    int numpts = 0;
     g_array_set_size(ptp->bezpointarray_data,len);
     for (i = 0; i < len; i++) {
       /* a tuple of at least (int,double,double) */
@@ -497,7 +498,15 @@
         bpt.p2 = bpt.p3 = bpt.p1;
       }
       g_array_index(ptp->bezpointarray_data,BezPoint,i) = bpt;
+      ++numpts;
     }
+    /* rather than crashing Dia with too few point handle it here */
+    if (numpts < 2) {
+      g_warning ("Too few BezPoints!");
+      return -1;
+    }
+    /* only count valid points */
+    g_array_set_size(ptp->bezpointarray_data,numpts);
     return 0;
   }
   return -1;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]