Fix crash when loading custom audio on client

This commit is contained in:
MysterD 2022-05-13 23:27:49 -07:00
parent 4bc13ef275
commit 5e86a3e9ac
1 changed files with 7 additions and 0 deletions

View File

@ -223,6 +223,13 @@ struct BassAudio* audio_load_internal(const char* filename, bool isStream) {
bassAudio->file = modFile;
// copy audio into rawData
if (modFile->fp == NULL) {
modFile->fp = fopen(modFile->cachedPath, "rb");
if (modFile->fp == NULL) {
LOG_ERROR("Could not open mod file: %s", modFile->cachedPath);
return NULL;
}
}
rewind(modFile->fp);
bassAudio->rawData = (char*)malloc(modFile->size * sizeof(char));
fread(bassAudio->rawData, modFile->size, 1, modFile->fp);