aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/log.c4
-rw-r--r--src/common/util.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/common/log.c b/src/common/log.c
index 5e2e6b5b5..5f0b4f8d9 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -833,8 +833,10 @@ add_file_log(const log_severity_list_t *severity, const char *filename)
fd = tor_open_cloexec(filename, O_WRONLY|O_CREAT|O_APPEND, 0644);
if (fd<0)
return -1;
- if (tor_fd_seekend(fd)<0)
+ if (tor_fd_seekend(fd)<0) {
+ close(fd);
return -1;
+ }
LOCK_LOGS();
add_stream_log_impl(severity, filename, fd);
diff --git a/src/common/util.c b/src/common/util.c
index 6fb597a3a..29aa83e5d 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));