backtrace: Support backtracing even if library is not initialized
authorMartin Willi <martin@revosec.ch>
Wed, 16 Oct 2013 10:32:15 +0000 (12:32 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 6 Nov 2013 09:31:00 +0000 (10:31 +0100)
But of course backtracing must be initialized anyway using backtrace_init().

src/libstrongswan/utils/backtrace.c

index fb2c4d1..f158462 100644 (file)
@@ -314,7 +314,7 @@ static void print_sourceline(FILE *file, char *filename, void *ptr, void *base)
        bool old = FALSE;
 
        bfd_mutex->lock(bfd_mutex);
-       if (lib->leak_detective)
+       if (lib && lib->leak_detective)
        {
                old = lib->leak_detective->set_state(lib->leak_detective, FALSE);
        }
@@ -324,7 +324,7 @@ static void print_sourceline(FILE *file, char *filename, void *ptr, void *base)
                data.entry = entry;
                bfd_map_over_sections(entry->abfd, (void*)find_addr, &data);
        }
-       if (lib->leak_detective)
+       if (lib && lib->leak_detective)
        {
                lib->leak_detective->set_state(lib->leak_detective, old);
        }