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

Commit 063bc245 authored by Kelvin Zhang's avatar Kelvin Zhang
Browse files

Fix memory leak in OTA verifier code

StartIteration() allocates some memory, which are release in
EndIteration(). Since we never called EndIteration(), these
memories are leaked.

Test: th
Bug: 233209345
Change-Id: I71c1d6eec16b8ac20c35e180f34fec50d0baec1a
parent 7c4d5acc
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -309,13 +309,15 @@ int verify_file(VerifierInterface* package, const std::vector<Certificate>& keys
}

static std::vector<Certificate> IterateZipEntriesAndSearchForKeys(const ZipArchiveHandle& handle) {
  void* cookie;
  void* cookie{};

  int32_t iter_status = StartIteration(handle, &cookie, "", "x509.pem");
  if (iter_status != 0) {
    LOG(ERROR) << "Failed to iterate over entries in the certificate zipfile: "
               << ErrorCodeString(iter_status);
    return {};
  }
  std::unique_ptr<void, decltype(&EndIteration)> cookie_guard(cookie, &EndIteration);

  std::vector<Certificate> result;