mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-25 22:19:10 +00:00
Stack allocation never happened, so explicitly allocate the path
This commit is contained in:
parent
4836fd1e70
commit
7b14fcb4d9
1 changed files with 3 additions and 5 deletions
|
@ -577,13 +577,11 @@ SDL_IOStream *SDL_IOFromFile(const char *file, const char *mode)
|
||||||
return SDL_IOFromFP(fp, SDL_TRUE);
|
return SDL_IOFromFP(fp, SDL_TRUE);
|
||||||
} else {
|
} else {
|
||||||
/* Try opening it from internal storage if it's a relative path */
|
/* Try opening it from internal storage if it's a relative path */
|
||||||
// !!! FIXME: why not just "char path[PATH_MAX];"
|
char *path = NULL;
|
||||||
char *path = SDL_stack_alloc(char, PATH_MAX);
|
SDL_asprintf(&path, "%s/%s", SDL_AndroidGetInternalStoragePath(), file);
|
||||||
if (path) {
|
if (path) {
|
||||||
SDL_snprintf(path, PATH_MAX, "%s/%s",
|
|
||||||
SDL_AndroidGetInternalStoragePath(), file);
|
|
||||||
FILE *fp = fopen(path, mode);
|
FILE *fp = fopen(path, mode);
|
||||||
SDL_stack_free(path);
|
SDL_free(path);
|
||||||
if (fp) {
|
if (fp) {
|
||||||
if (!IsRegularFileOrPipe(fp)) {
|
if (!IsRegularFileOrPipe(fp)) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue