From d3aabf4db176a44d19046b58b99f2edb8c5f49bb Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 28 Dec 2012 22:49:32 -0500 Subject: Fix various small leaks on error cases Spotted by coverity, bug 7816, bugfix on various versions. --- src/common/util.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/common/util.c') 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)); -- cgit v1.2.3-54-g00ecf