summaryrefslogtreecommitdiff
path: root/fastboot/fastboot.cpp
diff options
context:
space:
mode:
authorGreg Kaiser <gkaiser@google.com>2016-08-11 11:34:16 -0700
committerElliott Hughes <enh@google.com>2016-08-12 08:57:22 -0700
commitdc9b62ba74b276c05e4e6aede8cb63ea4ff53e4d (patch)
treef5fd4c90f72fc18a6dc51abe08d4b31a9d7cdda6 /fastboot/fastboot.cpp
parent07f14c9cdde718bface371d075ccc7f8bf16f098 (diff)
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. (cherry-pick of 407a2195391685627e6be947491041ae3c8cbe61.) Change-Id: I4e14cadc1e53bac0848e0e0c7f531f920e43cb0a
Diffstat (limited to 'fastboot/fastboot.cpp')
-rw-r--r--fastboot/fastboot.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index dde21d559..c097d045e 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -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;
}