From f64cd4b8e287d1e3bd1572b4593e0be657247473 Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 9 May 2022 04:12:54 -0700 Subject: [PATCH] Do a file type check on custom audio --- src/pc/lua/utils/smlua_audio_utils.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pc/lua/utils/smlua_audio_utils.c b/src/pc/lua/utils/smlua_audio_utils.c index 7e51deb0..b6e294f0 100644 --- a/src/pc/lua/utils/smlua_audio_utils.c +++ b/src/pc/lua/utils/smlua_audio_utils.c @@ -163,6 +163,22 @@ static bool audio_sanity_check(struct BassAudio* audio, bool isStream, const cha } struct BassAudio* audio_load_internal(const char* filename, bool isStream) { + // check file type + bool validFileType = false; + const char* fileTypes[] = { ".mp3", ".aiff", ".ogg", NULL }; + const char** ft = fileTypes; + while (*ft != NULL) { + if (str_ends_with((char*)filename, (char*)*ft)) { + validFileType = true; + break; + } + ft++; + } + if (!validFileType) { + LOG_LUA_LINE("Tried to load audio file with invalid file type: %s", filename); + return NULL; + } + // find mod file in mod list bool foundModFile = false; struct ModFile* modFile = NULL;