Fix use after free

This commit is contained in:
Maschell 2022-05-23 22:39:14 +02:00
parent 153d10acf9
commit 15a9847ae5

View File

@ -462,8 +462,9 @@ static int fs_dev_stat_r(struct _reent *r, const char *path, struct stat *st) {
FSStat stats;
int result = IOSUHAX_FSA_GetStat(dev->fsaFd, real_path, &stats);
free(real_path);
if (result < 0) {
free(real_path);
r->_errno = fs_dev_translate_error(result);
OSUnlockMutex(dev->pMutex);
return -1;
@ -484,6 +485,8 @@ static int fs_dev_stat_r(struct _reent *r, const char *path, struct stat *st) {
st->st_ctime = fs_dev_translate_time(stats.created);
st->st_mtime = fs_dev_translate_time(stats.modified);
free(real_path);
OSUnlockMutex(dev->pMutex);
return 0;
}
@ -509,8 +512,8 @@ static int fs_dev_lstat_r(struct _reent *r, const char *path, struct stat *st) {
FSStat stats;
int result = IOSUHAX_FSA_GetStat(dev->fsaFd, real_path, &stats);
free(real_path);
if (result < 0) {
free(real_path);
r->_errno = fs_dev_translate_error(result);
OSUnlockMutex(dev->pMutex);
return -1;
@ -531,6 +534,8 @@ static int fs_dev_lstat_r(struct _reent *r, const char *path, struct stat *st) {
st->st_ctime = fs_dev_translate_time(stats.created);
st->st_mtime = fs_dev_translate_time(stats.modified);
free(real_path);
OSUnlockMutex(dev->pMutex);
return 0;
}