Merge "fastboot: Don't leak file in error case"
am: 3a197b3799
Change-Id: Ieaab2ed5c1619f75fa4c334d61afaf858ad7d46c
This commit is contained in:
commit
0c8a67bbfd
1 changed files with 3 additions and 0 deletions
|
|
@ -579,6 +579,7 @@ static int unzip_to_file(ZipArchiveHandle zip, char* entry_name) {
|
||||||
ZipEntry zip_entry;
|
ZipEntry zip_entry;
|
||||||
if (FindEntry(zip, zip_entry_name, &zip_entry) != 0) {
|
if (FindEntry(zip, zip_entry_name, &zip_entry) != 0) {
|
||||||
fprintf(stderr, "archive does not contain '%s'\n", entry_name);
|
fprintf(stderr, "archive does not contain '%s'\n", entry_name);
|
||||||
|
fclose(fp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -586,10 +587,12 @@ static int unzip_to_file(ZipArchiveHandle zip, char* entry_name) {
|
||||||
int error = ExtractEntryToFile(zip, &zip_entry, fd);
|
int error = ExtractEntryToFile(zip, &zip_entry, fd);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
fprintf(stderr, "failed to extract '%s': %s\n", entry_name, ErrorCodeString(error));
|
fprintf(stderr, "failed to extract '%s': %s\n", entry_name, ErrorCodeString(error));
|
||||||
|
fclose(fp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
lseek(fd, 0, SEEK_SET);
|
lseek(fd, 0, SEEK_SET);
|
||||||
|
// TODO: We're leaking 'fp' here.
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue