leak-detective: take a copy of backtrace while printing traces
authorMartin Willi <martin@revosec.ch>
Wed, 10 Jul 2013 15:15:00 +0000 (17:15 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 10 Jul 2013 15:28:24 +0000 (17:28 +0200)
As we don't want to hold the lock, we must make sure backtraces keep valid
while printing them.

src/libstrongswan/utils/leak_detective.c

index aa24472..b2c644a 100644 (file)
@@ -637,11 +637,11 @@ static int print_traces(private_leak_detective_t *this,
                else
                {
                        INIT(entry,
-                               .backtrace = hdr->backtrace,
+                               .backtrace = hdr->backtrace->clone(hdr->backtrace),
                                .bytes = hdr->bytes,
                                .count = 1,
                        );
-                       entries->put(entries, hdr->backtrace, entry);
+                       entries->put(entries, entry->backtrace, entry);
                }
                leaks++;
        }
@@ -655,6 +655,7 @@ static int print_traces(private_leak_detective_t *this,
                                        entry->bytes, entry->count, entry->bytes / entry->count);
                        entry->backtrace->log(entry->backtrace, out, detailed);
                }
+               entry->backtrace->destroy(entry->backtrace);
                free(entry);
        }
        enumerator->destroy(enumerator);