fastboot: Don't leak file in error case
This is probably not very significant in this standalone tool,
but makes it easier for us to find leaks in our other system
code via static analysis.
Change-Id: I4e14cadc1e53bac0848e0e0c7f531f920e43cb0a
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;
}