[SVACE/414949] Fix 65505047 Warning
authorjijoong.moon <jijoong.moon@samsung.com>
Mon, 1 Apr 2019 08:07:40 +0000 (17:07 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Tue, 2 Apr 2019 07:31:33 +0000 (16:31 +0900)
Line 448 of unittest_common.cpp has svace warning:

WID:65505047 Return value of a function 'fopen64' is dereferenced at
unittest_common.cpp:448 without checking, but it is usually checked
for this function (8/9).

**Self evaluation:**
1. Build test:  [X]Passed [ ]Failed [ ]Skipped
2. Run test:  [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: jijoong.moon <jijoong.moon@samsung.com>
tests/common/unittest_common.cpp

index ee655f7..6e6b9bb 100644 (file)
@@ -445,7 +445,12 @@ static gchar *create_null_file (const gchar *dir, const gchar *file)
   gchar *fullpath = g_build_path ("/", dir, file, NULL);
   FILE *fp = g_fopen (fullpath, "w");
 
-  fclose (fp);
+  if (fp) {
+    fclose (fp);
+  } else {
+    g_free (fullpath);
+    return NULL;
+  }
   return fullpath;
 }