OSDN Git Service

Fix a segfault in ped_assert() where the wrong pointer is freed in the backtrace.
authorDavid Cantrell <dcantrel@mortise.boston.redhat.com>
Fri, 12 Jan 2007 15:07:17 +0000 (10:07 -0500)
committerDavid Cantrell <dcantrel@mortise.boston.redhat.com>
Fri, 12 Jan 2007 15:14:58 +0000 (10:14 -0500)
(cherry picked from commit 63f7b33b352d0d699efeb1095340ed6139c49e3b)

libparted/debug.c

index 0c3d583..87d891e 100644 (file)
@@ -95,16 +95,18 @@ int ped_assert ( int cond, const char* cond_text,
        /* Print backtrace stack */
        void *stack[20];
        size_t size;
-       char **strings;
+       char **strings, **string;
        
        size = backtrace(stack, 20);
        strings = backtrace_symbols(stack, size);
 
-       printf(_("Backtrace has %d calls on stack:\n"), size);
-       for (; size > 0; size--, strings++)
-               printf("  %d: %s\n", size, *strings);
+       if (strings) {
+               printf(_("Backtrace has %d calls on stack:\n"), size);
+               for (string = strings; size > 0; size--, string++)
+                       printf("  %d: %s\n", size, *string);
 
-       free(strings);
+               free(strings);
+       }
 #endif
 
        /* Throw the exception */