Merge "fastboot: Don't leak file in error case"

This commit is contained in:
Treehugger Robot 2016-08-12 17:34:49 +00:00 committed by Gerrit Code Review
commit 3a197b3799
1 changed files with 3 additions and 0 deletions

View File

@ -519,6 +519,7 @@ static int unzip_to_file(ZipArchiveHandle zip, char* entry_name) {
ZipEntry zip_entry;
if (FindEntry(zip, zip_entry_name, &zip_entry) != 0) {
fprintf(stderr, "archive does not contain '%s'\n", entry_name);
fclose(fp);
return -1;
}
@ -526,10 +527,12 @@ static int unzip_to_file(ZipArchiveHandle zip, char* entry_name) {
int error = ExtractEntryToFile(zip, &zip_entry, fd);
if (error != 0) {
fprintf(stderr, "failed to extract '%s': %s\n", entry_name, ErrorCodeString(error));
fclose(fp);
return -1;
}
lseek(fd, 0, SEEK_SET);
// TODO: We're leaking 'fp' here.
return fd;
}