commit | 5799d65f120ee3aa14a607fd2cd24ee8e03bc7d6 | [log] [tgz] |
---|---|---|
author | Greg Kaiser <gkaiser@google.com> | Mon Mar 26 14:01:38 2018 -0700 |
committer | Greg Kaiser <gkaiser@google.com> | Mon Mar 26 14:01:38 2018 -0700 |
tree | 1af34b00f7c73144274a0eaddf936f5da02d94b4 | |
parent | fe3877f140d9f86406708b7ac40366f43175906d [diff] [blame] |
tools/bit: Avoid leak in error condition In the unlikely event of fread() failing, we want to avoid leaking our buffer or the file handle. Test: Treehugger Change-Id: I1866d00c74ad38af4559d747fee696a60464c9f0
diff --git a/tools/bit/util.cpp b/tools/bit/util.cpp index 9223931..a502a9d 100644 --- a/tools/bit/util.cpp +++ b/tools/bit/util.cpp
@@ -241,6 +241,8 @@ char* buf = (char*)malloc(size); if ((size_t) size != fread(buf, 1, size, file)) { + free(buf); + fclose(file); return string(); }