]> granicus.if.org Git - libevent/commitdiff
Close the file in evutil_read_file whether there's an error or not.
authorPierre Phaneuf <pphaneuf@gmail.com>
Fri, 28 May 2010 02:37:09 +0000 (22:37 -0400)
committerPierre Phaneuf <pphaneuf@gmail.com>
Fri, 28 May 2010 02:37:09 +0000 (22:37 -0400)
evutil_read_file would close the file if there was an error, but not if things went normally.

evutil.c

index 1dfc427aa39f7322a38b66e45d0543fb825a7cab..d0621bfacfbb4e54c7ab971c7b768cc1b9bbc8e1 100644 (file)
--- a/evutil.c
+++ b/evutil.c
@@ -127,8 +127,8 @@ evutil_read_file(const char *filename, char **content_out, size_t *len_out,
                        break;
                EVUTIL_ASSERT(read_so_far < st.st_size);
        }
+       close(fd);
        if (r < 0) {
-               close(fd);
                mm_free(mem);
                return -2;
        }