[Bf-blender-cvs] [4da651c] master: Fix T37472: crash when packing UV islands.
Campbell Barton
noreply at git.blender.org
Tue Nov 19 01:40:30 CET 2013
Commit: 4da651c8f0ffc3b0cc21752cbcaed5e10f228a86
Author: Campbell Barton
Date: Tue Nov 19 11:18:00 2013 +1100
http://developer.blender.org/rB4da651c8f0ffc3b0cc21752cbcaed5e10f228a86
Fix T37472: crash when packing UV islands.
===================================================================
M source/blender/blenlib/intern/convexhull2d.c
M source/blender/python/mathutils/mathutils_geometry.c
===================================================================
diff --git a/source/blender/blenlib/intern/convexhull2d.c b/source/blender/blenlib/intern/convexhull2d.c
index 5669a30..2c29ef0 100644
--- a/source/blender/blenlib/intern/convexhull2d.c
+++ b/source/blender/blenlib/intern/convexhull2d.c
@@ -191,6 +191,8 @@ static int pointref_cmp_y(const void *a_, const void *b_)
* \param points An array of 2D points.
* \param n The number of points in points.
* \param r_points An array of the convex hull vertex indices (max is n).
+ * _must_ be allocated as ``n * 2`` becauise of how its used internally,
+ * even though the final result will be no more then \a n in size.
* \returns the number of points in r_points.
*/
int BLI_convexhull_2d(const float (*points)[2], const int n, int r_points[])
@@ -310,7 +312,7 @@ float BLI_convexhull_aabb_fit_points_2d(const float (*points)[2], unsigned int n
float angle;
- index_map = MEM_mallocN(sizeof(*index_map) * n, __func__);
+ index_map = MEM_mallocN(sizeof(*index_map) * n * 2, __func__);
tot = BLI_convexhull_2d((const float (*)[2])points, (int)n, index_map);
diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c
index 8b5b74c..584861d 100644
--- a/source/blender/python/mathutils/mathutils_geometry.c
+++ b/source/blender/python/mathutils/mathutils_geometry.c
@@ -1563,7 +1563,7 @@ static PyObject *M_Geometry_convex_hull_2d(PyObject *UNUSED(self), PyObject *poi
int *index_map;
Py_ssize_t len_ret, i;
- index_map = MEM_mallocN(sizeof(*index_map) * len, __func__);
+ index_map = MEM_mallocN(sizeof(*index_map) * len * 2, __func__);
/* Non Python function */
len_ret = BLI_convexhull_2d((const float (*)[2])points, len, index_map);
More information about the Bf-blender-cvs
mailing list