OSDN Git Service
(root)
/
android-x86
/
frameworks-base.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
fe3877f
)
tools/bit: Avoid leak in error condition
author
Greg Kaiser
<gkaiser@google.com>
Mon, 26 Mar 2018 21:01:38 +0000
(14:01 -0700)
committer
Greg Kaiser
<gkaiser@google.com>
Mon, 26 Mar 2018 21:01:38 +0000
(14:01 -0700)
In the unlikely event of fread() failing, we want to avoid leaking
our buffer or the file handle.
Test: Treehugger
Change-Id: I1866d00c74ad38af4559d747fee696a60464c9f0
tools/bit/util.cpp
patch
|
blob
|
history
diff --git
a/tools/bit/util.cpp
b/tools/bit/util.cpp
index
9223931
..
a502a9d
100644
(file)
--- a/
tools/bit/util.cpp
+++ b/
tools/bit/util.cpp
@@
-241,6
+241,8
@@
read_file(const string& filename)
char* buf = (char*)malloc(size);
if ((size_t) size != fread(buf, 1, size, file)) {
+ free(buf);
+ fclose(file);
return string();
}