aboutsummaryrefslogtreecommitdiff
path: root/src/lzmadec/lzmadec.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-01-15 17:46:59 +0200
committerLasse Collin <lasse.collin@tukaani.org>2008-01-15 17:46:59 +0200
commit01d71d60b79027e1ce3eb9c79ae5191e1407c883 (patch)
tree8b0276d51162ae704291d7ad4874a4e6b5ca0fe3 /src/lzmadec/lzmadec.c
parentFix memory leaks from test_block_header.c. (diff)
downloadxz-01d71d60b79027e1ce3eb9c79ae5191e1407c883.tar.xz
Free the allocated memory in lzmadec if debugging is
enabled. This should make it possible to detect possible memory leaks with Valgrind.
Diffstat (limited to '')
-rw-r--r--src/lzmadec/lzmadec.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lzmadec/lzmadec.c b/src/lzmadec/lzmadec.c
index fef49249..f0ae3568 100644
--- a/src/lzmadec/lzmadec.c
+++ b/src/lzmadec/lzmadec.c
@@ -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;
}