Merge "fastboot: Don't leak file in error case" am: 3a197b3799 am: 0c8a67bbfd
am: 3ab37d8844
Change-Id: I1bc5d9183e116819c4e92ed6f29e63936a334740
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index 314ed42..ce8df88 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -599,6 +599,7 @@
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;
}
@@ -606,10 +607,12 @@
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;
}