Fix accessing cleared memory

Fixed a major bug whereby file names were being retrieved from a cleared
pointer (issue 9).

Tested working on n3DS.

Signed-off-by: Mahyar Koshkouei <deltabeard@users.noreply.github.com>
This commit is contained in:
Mahyar Koshkouei
2016-12-30 18:28:32 +00:00
parent 42b61ba7f0
commit 19b96191de

View File

@@ -131,14 +131,6 @@ int main(int argc, char **argv)
break;
}
if(closedir(dp) != 0)
err_print("Closing directory failed.");
/**
* TODO: There is an issue with Unicode files here.
* Playing a flac file then a file with a name containing the
* character 'é' will cause the asprint to not work properly.
*/
if(asprintf(&file, "%s%s", AUDIO_FOLDER, ep->d_name) == -1)
{
err_print("Constructing file name failed.");
@@ -164,6 +156,9 @@ int main(int argc, char **argv)
printf("Unsupported File type.\n");
}
}
if(closedir(dp) != 0)
err_print("Closing directory failed.");
}
else
err_print("Unable to open directory.");