sample: Added error checking for fseek 41/198341/2
authorJoonbum Ko <joonbum.ko@samsung.com>
Thu, 24 Jan 2019 02:40:26 +0000 (11:40 +0900)
committerJoonbum Ko <joonbum.ko@samsung.com>
Thu, 24 Jan 2019 02:46:49 +0000 (11:46 +0900)
Change-Id: I6a4a0068095a1103fa582eeeba5f1ac5e775e251
Signed-off-by: Joonbum Ko <joonbum.ko@samsung.com>
samples/tri.c

index df4734b..b42cd55 100644 (file)
@@ -1250,14 +1250,21 @@ char *demo_read_spv(const char *filename, size_t *psize) {
     if (!fp)
         return NULL;
 
-    fseek(fp, 0L, SEEK_END);
+    if (fseek(fp, 0L, SEEK_END) == -1) {
+        fclose(fp);
+        return NULL;
+    }
+
     size = ftell(fp);
     if (size < 0) {
         fclose(fp);
         return NULL;
     }
 
-    fseek(fp, 0L, SEEK_SET);
+    if (fseek(fp, 0L, SEEK_SET) == -1) {
+        fclose(fp);
+        return NULL;
+    }
 
     shader_code = malloc(size);
     retVal = fread(shader_code, size, 1, fp);