diff options
author | Alex Deymo <deymo@google.com> | 2018-02-14 19:18:49 +0100 |
---|---|---|
committer | Alex Deymo <deymo@google.com> | 2018-02-14 20:47:10 +0100 |
commit | cdd45ca1c8c3bfa72058e2fba70f9a96a27ff2fe (patch) | |
tree | f7ee1e3187d961766a0682e1768f839c0f47ad47 | |
parent | 46e8a3d9bd4d6cd77b8556fb243a18f4e886cb0e (diff) | |
download | bsdiff-cdd45ca1c8c3bfa72058e2fba70f9a96a27ff2fe.tar.gz |
munmap() buffers after running bsdiff in main.
We were technically leaking mmap'ed memory in the main program. This
was not really a problem in normal execution of the binary because the
process would finish right after it, but releasing the mmap() helps
find actual leaks when instrumenting the code with asan tools.
Bug: None
Test: ran bsdiff over a sample file.
Change-Id: I5fac808ba6d0ba9b2331e40a764cac1a3620062f
-rw-r--r-- | bsdiff_main.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/bsdiff_main.cc b/bsdiff_main.cc index 1465441..6747055 100644 --- a/bsdiff_main.cc +++ b/bsdiff_main.cc @@ -85,8 +85,13 @@ int GenerateBsdiffFromFiles(const char* old_filename, return 1; } - return bsdiff::bsdiff(old_buf, oldsize, new_buf, newsize, - arguments.min_length(), patch_writer.get(), nullptr); + int ret = bsdiff::bsdiff(old_buf, oldsize, new_buf, newsize, + arguments.min_length(), patch_writer.get(), nullptr); + + munmap(old_buf, oldsize); + munmap(new_buf, newsize); + + return ret; } void PrintUsage(const std::string& proc_name) { |