mirror of
https://codeberg.org/1414codeforge/ubgpsuite.git
synced 2025-02-03 04:07:36 +01:00
[lonetix/fs] Make Sys_ListFiles() safer when NULL is returned, by clearing *nfiles
This commit is contained in:
parent
c195ecd8d7
commit
dbd36e302c
@ -215,6 +215,9 @@ char **Sys_ListFiles(const char *path, unsigned *nfiles, const char *pat)
|
||||
if (errno != ENOENT && errno != ENOTDIR)
|
||||
Sys_SetErrStat(errno, "opendir()");
|
||||
|
||||
if (nfiles)
|
||||
*nfiles = 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -321,6 +324,10 @@ char **Sys_ListFiles(const char *path, unsigned *nfiles, const char *pat)
|
||||
|
||||
fail:
|
||||
closedir(dir);
|
||||
|
||||
if (nfiles)
|
||||
*nfiles = 0;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user