fix read_file: close file on success
Stefan Schuermans

Stefan Schuermans commited on 2021-01-12 20:46:31
Showing 1 changed files, with 2 additions and 1 deletions.

... ...
@@ -42,8 +42,9 @@ char *uptev_read_file(char const *pathname, size_t *size) {
42 42
       return NULL;
43 43
     }
44 44
     if (len == 0) {
45
-      /* end of file -> return data */
45
+      /* end of file -> close file and return data */
46 46
       *size = pos;
47
+      close(fd);
47 48
       return data;
48 49
     }
49 50
     /* data read -> add to buffer */
50 51