diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-12-28 22:49:32 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-12-28 22:49:32 -0500 |
commit | d3aabf4db176a44d19046b58b99f2edb8c5f49bb (patch) | |
tree | d804e239d5e0c4993c82f40cb97b25a1f7f73132 /src/common/util.c | |
parent | b509ead20d93277697c1cb961a2ae520bce7fd7f (diff) | |
download | tor-d3aabf4db176a44d19046b58b99f2edb8c5f49bb.tar.gz tor-d3aabf4db176a44d19046b58b99f2edb8c5f49bb.zip |
Fix various small leaks on error cases
Spotted by coverity, bug 7816, bugfix on various versions.
Diffstat (limited to 'src/common/util.c')
-rw-r--r-- | src/common/util.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/common/util.c b/src/common/util.c index 6fb597a3a5..29aa83e5d6 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -2305,8 +2305,10 @@ read_file_to_str(const char *filename, int flags, struct stat *stat_out) return NULL; } - if ((uint64_t)(statbuf.st_size)+1 >= SIZE_T_CEILING) + if ((uint64_t)(statbuf.st_size)+1 >= SIZE_T_CEILING) { + close(fd); return NULL; + } string = tor_malloc((size_t)(statbuf.st_size+1)); |