[hitori] interface: Fix a leak in the redo stack handling



commit e13c862141299db1bbebffa958c56518da5d64c9
Author: Philip Withnall <philip tecnocode co uk>
Date:   Wed Jun 11 10:03:58 2014 +0100

    interface: Fix a leak in the redo stack handling

 src/interface.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/src/interface.c b/src/interface.c
index 295cdfc..2ec969b 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -359,8 +359,17 @@ hitori_button_release_cb (GtkWidget *drawing_area, GdkEventButton *event, Hitori
 
        hitori->made_a_move = TRUE;
 
-       if (hitori->undo_stack != NULL)
+       if (hitori->undo_stack != NULL) {
+               HitoriUndo *i, *next = NULL;
+
+               /* Free the redo stack after this point. */
+               for (i = hitori->undo_stack->redo; i != NULL; i = next) {
+                       next = i->redo;
+                       g_free (i);
+               }
+
                hitori->undo_stack->redo = undo;
+       }
        hitori->undo_stack = undo;
        g_simple_action_set_enabled (hitori->undo_action, TRUE);
        g_simple_action_set_enabled (hitori->redo_action, FALSE);


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