Forráskód Böngészése

Stack allocation never happened, so explicitly allocate the path

Sam Lantinga 10 hónapja
szülő
commit
7b14fcb4d9
1 módosított fájl, 3 hozzáadás és 5 törlés
  1. 3 5
      src/file/SDL_iostream.c

+ 3 - 5
src/file/SDL_iostream.c

@@ -577,13 +577,11 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode)
         return SDL_IOFromFP(fp, SDL_TRUE);
     } else {
         /* Try opening it from internal storage if it's a relative path */
-        // !!! FIXME: why not just "char path[PATH_MAX];"
-        char *path = SDL_stack_alloc(char, PATH_MAX);
+        char *path = NULL;
+        SDL_asprintf(&path, "%s/%s", SDL_AndroidGetInternalStoragePath(), file);
         if (path) {
-            SDL_snprintf(path, PATH_MAX, "%s/%s",
-                         SDL_AndroidGetInternalStoragePath(), file);
             FILE *fp = fopen(path, mode);
-            SDL_stack_free(path);
+            SDL_free(path);
             if (fp) {
                 if (!IsRegularFileOrPipe(fp)) {
                     fclose(fp);