slackbuilds_ponce/graphics/dia/patches/0007-grid-object-avoid-crash-on-shrink.patch
Matteo Bernardini bce367d60b graphics/dia: Applied patches from upstream.
Signed-off-by: Matteo Bernardini <ponce@slackbuilds.org>
2013-11-28 00:13:12 -06:00

46 lines
1.9 KiB
Diff

From ae8bcaa703197d090c0c746c54289ddcc6bbbbb1 Mon Sep 17 00:00:00 2001
From: Hans Breuer <hans@breuer.org>
Date: Thu, 7 Oct 2010 13:21:16 +0200
Subject: [PATCH 07/24] grid-object: avoid crash on shrink
Fix some confusion about rows/columns using the wrong limits.
Resizing object::connections was too early.
(cherry picked from commit cddd958b71a4075751ab76ac3530ced3c33972ea)
---
objects/Misc/grid_object.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/objects/Misc/grid_object.c b/objects/Misc/grid_object.c
index 05d1b16..11dca8b 100644
--- a/objects/Misc/grid_object.c
+++ b/objects/Misc/grid_object.c
@@ -460,12 +460,6 @@ grid_object_reallocate_cells (Grid_Object* grid_object)
if (old_rows == new_rows && old_cols == new_cols)
return; /* no reallocation necessary */
- /* obj->connections doesn't own the pointers, so just realloc; values
- * will be updated later */
- obj->num_connections = GRID_OBJECT_BASE_CONNECTION_POINTS + new_rows*new_cols;
- obj->connections = (ConnectionPoint **) g_realloc(obj->connections,
- obj->num_connections * sizeof(ConnectionPoint *));
-
/* If either new dimension is smaller, some connpoints will have to
* be disconnected before reallocating */
@@ -485,6 +479,13 @@ grid_object_reallocate_cells (Grid_Object* grid_object)
object_remove_connections_to(&grid_object->cells[cell]);
}
+ /* must be done after disconnecting */
+ /* obj->connections doesn't own the pointers, so just realloc; values
+ * will be updated later */
+ obj->num_connections = GRID_OBJECT_BASE_CONNECTION_POINTS + new_rows*new_cols;
+ obj->connections = (ConnectionPoint **) g_realloc(obj->connections,
+ obj->num_connections * sizeof(ConnectionPoint *));
+
/* Can't use realloc; if grid has different dims, memory lays out
* differently. Must copy by hand. */
--
1.8.4.4