mirror of
https://github.com/libretro/RetroArch
synced 2025-03-23 10:20:57 +00:00
Merge pull request #6571 from hiddenasbestos/retro_opendir_r2
retro_opendir - Improved fix for bad input
This commit is contained in:
commit
4c39a7fd78
@ -106,14 +106,16 @@ struct RDIR *retro_opendir(const char *name)
|
|||||||
wchar_t *path_wide = NULL;
|
wchar_t *path_wide = NULL;
|
||||||
unsigned path_len;
|
unsigned path_len;
|
||||||
#endif
|
#endif
|
||||||
struct RDIR *rdir = (struct RDIR*)calloc(1, sizeof(*rdir));
|
struct RDIR *rdir;
|
||||||
|
|
||||||
if (!rdir||!name)
|
/*Reject null or empty string paths*/
|
||||||
{
|
if (!name||(*name==0))
|
||||||
if (rdir)
|
return NULL;
|
||||||
free(rdir);
|
|
||||||
|
/*Allocate RDIR struct. Tidied later with retro_closedir*/
|
||||||
|
rdir = (struct RDIR*)calloc(1, sizeof(*rdir));
|
||||||
|
if (!rdir)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
(void)path_wide;
|
(void)path_wide;
|
||||||
|
@ -32,6 +32,16 @@ RETRO_BEGIN_DECLS
|
|||||||
|
|
||||||
typedef struct RDIR RDIR;
|
typedef struct RDIR RDIR;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* retro_opendir:
|
||||||
|
* @name : path to the directory to open.
|
||||||
|
*
|
||||||
|
* Opens a directory for reading. Tidy up with retro_closedir.
|
||||||
|
*
|
||||||
|
* Returns: RDIR pointer on success, NULL if name is not a
|
||||||
|
* valid directory, null itself or the empty string.
|
||||||
|
*/
|
||||||
struct RDIR *retro_opendir(const char *name);
|
struct RDIR *retro_opendir(const char *name);
|
||||||
|
|
||||||
int retro_readdir(struct RDIR *rdir);
|
int retro_readdir(struct RDIR *rdir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user