[gtk+/a11y] tests: Fix crash due to freeing random pointers



commit 566872e907bf573e11eb5ba2791faafbf3af1025
Author: Benjamin Otte <otte redhat com>
Date:   Tue Jun 21 18:14:40 2011 +0200

    tests: Fix crash due to freeing random pointers

 tests/a11y/accessibility-dump.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
---
diff --git a/tests/a11y/accessibility-dump.c b/tests/a11y/accessibility-dump.c
index 6aba659..d91df61 100644
--- a/tests/a11y/accessibility-dump.c
+++ b/tests/a11y/accessibility-dump.c
@@ -688,7 +688,6 @@ dump_to_stdout (GFile *file)
 static void
 test_ui_file (GFile *file)
 {
-  char *diff;
   char *ui_file, *a11y_file;
   GString *dump;
   GError *error = NULL;
@@ -701,13 +700,14 @@ test_ui_file (GFile *file)
 
   if (a11y_file)
     {
-      diff = diff_with_file (a11y_file, dump->str, dump->len, &error);
+      char *diff = diff_with_file (a11y_file, dump->str, dump->len, &error);
       g_assert_no_error (error);
 
       if (diff && diff[0])
         {
           g_test_message ("Contents don't match expected contents:\n%s", diff);
           g_test_fail ();
+          g_free (diff);
         }
     }
   else if (dump->str[0])
@@ -717,7 +717,6 @@ test_ui_file (GFile *file)
     }
 
   g_string_free (dump, TRUE);
-  g_free (diff);
   g_free (a11y_file);
   g_free (ui_file);
 }



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