Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0955d208 authored by Mårten Kongstad's avatar Mårten Kongstad Committed by Todd Kennedy
Browse files

idmap2: ZipFile::Open: fix potential memory leak

Even if OpenArchive in libziparchive returns a non-zero value
(indicating failure), it will have allocated memory that needs to be
freed via CloseArchive. Add the missing call.

Test: valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 $ANDROID_HOST_OUT/nativetest64/idmap2_tests/idmap2_tests
Change-Id: I92d47459c27e62ba4544327d7b7f3c4106e6ad34
parent e2415eee
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ std::unique_ptr<const ZipFile> ZipFile::Open(const std::string& path) {
  ::ZipArchiveHandle handle;
  int32_t status = ::OpenArchive(path.c_str(), &handle);
  if (status != 0) {
    ::CloseArchive(handle);
    return nullptr;
  }
  return std::unique_ptr<ZipFile>(new ZipFile(handle));