Fix null file pointer close 27/235627/1 accepted/tizen/unified/20200608.144728 submit/tizen/20200608.031722 submit/tizen/20200608.083617
authorJeon Sang-Heon <sh95.jeon@samsung.com>
Mon, 8 Jun 2020 07:22:32 +0000 (16:22 +0900)
committerJeon Sang-Heon <sh95.jeon@samsung.com>
Mon, 8 Jun 2020 07:22:32 +0000 (16:22 +0900)
- If failed to open file at util_file_write_line, it leads to fclose
with null pointer, So it can be lead to segmentation fault
- So fix it with closing null file pointer only file pointer is not null

Change-Id: Ic33b23e6c2fddfad70fd34f12e536d5a25cc69e9
Signed-off-by: Jeon Sang-Heon <sh95.jeon@samsung.com>
update-manager/util.c

index eeba812b5f87e81aacf66c26440bb41e194363d5..80b115ab6f99332891c300a3d191e2113cb58928 100644 (file)
@@ -49,11 +49,11 @@ int util_file_write_line(const char *path, const char *msg)
             _E("Failed to write, path : %s, msg : %s", path, msg);
             status = -1;
         }
+        fclose(fp);
     } else {
         _E("Failed to open : %s", path);
         status = -1;
     }
-    fclose(fp);
 
     return status;
 }