Prevent ASAN runtime error

This commit is contained in:
twinaphex 2019-08-28 07:44:13 +02:00
parent 88dabc7260
commit ca3a7aa654

View File

@ -1229,21 +1229,28 @@ bool retro_vfs_readdir_impl(libretro_vfs_implementation_dir *rdir)
const char *retro_vfs_dirent_get_name_impl(libretro_vfs_implementation_dir *rdir)
{
if (!rdir)
return NULL;
#if defined(_WIN32)
#if defined(LEGACY_WIN32)
char *name_local = local_to_utf8_string_alloc(rdir->entry.cFileName);
memset(rdir->entry.cFileName, 0, sizeof(rdir->entry.cFileName));
strlcpy(rdir->entry.cFileName, name_local, sizeof(rdir->entry.cFileName));
{
char *name_local = local_to_utf8_string_alloc(rdir->entry.cFileName);
memset(rdir->entry.cFileName, 0, sizeof(rdir->entry.cFileName));
strlcpy(rdir->entry.cFileName, name_local, sizeof(rdir->entry.cFileName));
if (name_local)
free(name_local);
if (name_local)
free(name_local);
}
#else
char *name = utf16_to_utf8_string_alloc(rdir->entry.cFileName);
memset(rdir->entry.cFileName, 0, sizeof(rdir->entry.cFileName));
strlcpy((char*)rdir->entry.cFileName, name, sizeof(rdir->entry.cFileName));
{
char *name = utf16_to_utf8_string_alloc(rdir->entry.cFileName);
memset(rdir->entry.cFileName, 0, sizeof(rdir->entry.cFileName));
strlcpy((char*)rdir->entry.cFileName, name, sizeof(rdir->entry.cFileName));
if (name)
free(name);
if (name)
free(name);
}
#endif
return (char*)rdir->entry.cFileName;
#elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__) || defined(ORBIS)
@ -1251,7 +1258,6 @@ const char *retro_vfs_dirent_get_name_impl(libretro_vfs_implementation_dir *rdir
#elif defined(PS2)
return rdir->entry.name;
#else
return rdir->entry->d_name;
#endif
}