Fix a bunch of small system/core bugs.
Missing frees in:
adb/file_sync_client.c
fastboot/fastboot.c
libsparse/output_file.c
Missing closedirs in:
adb/file_sync_service.c
cpio/mkbootfs.c
libcutils/dir_hash.c
Potential buffer overrun in:
gpttool/gpttool.c
Incorrect NULL check in:
libsparse/backed_block.c
Bug: https://code.google.com/p/android/issues/detail?id=61564
Change-Id: If97838a9e73a77aef7f416c31c237ce1fca4ce21
diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c
index 70b838f..da2af41 100644
--- a/fastboot/fastboot.c
+++ b/fastboot/fastboot.c
@@ -449,7 +449,13 @@
for(n = 0; n < count; n++) {
out[n] = strdup(strip(val[n]));
- if (out[n] == 0) return -1;
+ if (out[n] == 0) {
+ for(size_t i = 0; i < n; ++i) {
+ free((char*) out[i]);
+ }
+ free(out);
+ return -1;
+ }
}
fb_queue_require(prod, name, invert, n, out);