Skip to content

Commit

Permalink
recovery: Fix the crash caused by StartIteration
Browse files Browse the repository at this point in the history
In the new version of libziparchive, the default values ​​of the optional_prefix and optional_suffix parameters of the StartIteration function are changed to empty strings, and nullptr is no longer detected.

Change-Id: I66ee58a9515586700b10a3d5aa5b780a6207b33c
  • Loading branch information
sekaiacg authored and uixdess committed Dec 27, 2021
1 parent aade571 commit 2e9bd44
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion install/ZipUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bool ExtractPackageRecursive(ZipArchiveHandle zip, const std::string& zip_path,
}

const std::string zip_prefix(prefix_path.c_str());
int ret = StartIteration(zip, &cookie, zip_prefix, nullptr);
int ret = StartIteration(zip, &cookie, zip_prefix);

if (ret != 0) {
LOG(ERROR) << "failed to start iterating zip entries.";
Expand Down
2 changes: 1 addition & 1 deletion twrpinstall/ZipUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bool ExtractPackageRecursive(ZipArchiveHandle zip, const std::string& zip_path,
}
const ZipString zip_prefix(prefix_path.c_str());

int ret = StartIteration(zip, &cookie, &zip_prefix, nullptr);
int ret = StartIteration(zip, &cookie, &zip_prefix);
if (ret != 0) {
LOG(ERROR) << "failed to start iterating zip entries.";
return false;
Expand Down
2 changes: 1 addition & 1 deletion twrpinstall/installcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ bool verify_package_compatibility(ZipArchiveHandle zw) {

// Iterate all the entries inside COMPATIBILITY_ZIP_ENTRY and read the contents.
void* cookie;
ret = StartIteration(zip_handle, &cookie, nullptr, nullptr);
ret = StartIteration(zip_handle, &cookie);
if (ret != 0) {
printf("Failed to start iterating zip entries: %s\n", ErrorCodeString(ret));
CloseArchive(zip_handle);
Expand Down

0 comments on commit 2e9bd44

Please sign in to comment.