loader: Remove SEEK_END usage
authorLenny Komow <lenny@lunarg.com>
Tue, 1 Dec 2020 17:49:01 +0000 (10:49 -0700)
committerLenny Komow <lenny@lunarg.com>
Tue, 1 Dec 2020 20:49:37 +0000 (13:49 -0700)
Change-Id: I699caaf048d70756649d9f6a2c7dfb012c6d2342

loader/loader.c

index 8c414104c242a1c165db67d6b207926ae222541a..c1b4cc1cb3e8401456633495a5ba6d532d7873cb 100644 (file)
@@ -2652,7 +2652,12 @@ static VkResult loader_get_json(const struct loader_instance *inst, const char *
         res = VK_ERROR_INITIALIZATION_FAILED;
         goto out;
     }
-    fseek(file, 0, SEEK_END);
+    // NOTE: We can't just use fseek(file, 0, SEEK_END) because that isn't guaranteed to be supported on all systems
+    do {
+        // We're just seeking the end of the file, so this buffer is never used
+        char buffer[256];
+        fread(buffer, 1, sizeof(buffer), file);
+    } while (!feof(file));
     len = ftell(file);
     fseek(file, 0, SEEK_SET);
     json_buf = (char *)loader_stack_alloc(len + 1);