Free the allocated memory in lzmadec if debugging is
authorLasse Collin <lasse.collin@tukaani.org>
Tue, 15 Jan 2008 15:46:59 +0000 (17:46 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Tue, 15 Jan 2008 15:46:59 +0000 (17:46 +0200)
enabled. This should make it possible to detect possible
memory leaks with Valgrind.

src/lzmadec/lzmadec.c

index fef4924..f0ae356 100644 (file)
@@ -513,5 +513,12 @@ main(int argc, char **argv)
                } while (++optind < argc);
        }
 
+#ifndef NDEBUG
+       // Free the memory only when debugging. Freeing wastes some time,
+       // but allows detecting possible memory leaks with Valgrind.
+       lzma_end(&strm);
+       lzma_memlimit_end(mem_limitter, false);
+#endif
+
        return exit_status;
 }