6432: check for success when decoding audio r=Robyt3 a=Marmare314

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: marmare314 <49279081+Marmare314@users.noreply.github.com>
This commit is contained in:
bors[bot] 2023-03-17 09:53:42 +00:00 committed by GitHub
commit e5a51d5952
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -608,6 +608,8 @@ int CSound::LoadOpus(const char *pFilename)
SampleID = DecodeOpus(SampleID, pData, DataSize);
free(pData);
if(SampleID < 0)
return -1;
if(g_Config.m_Debug)
dbg_msg("sound/opus", "loaded %s", pFilename);
@ -648,6 +650,8 @@ int CSound::LoadWV(const char *pFilename)
SampleID = DecodeWV(SampleID, pData, DataSize);
free(pData);
if(SampleID < 0)
return -1;
if(g_Config.m_Debug)
dbg_msg("sound/wv", "loaded %s", pFilename);
@ -703,6 +707,8 @@ int CSound::LoadWVFromMem(const void *pData, unsigned DataSize, bool FromEditor
return -1;
SampleID = DecodeWV(SampleID, pData, DataSize);
if(SampleID < 0)
return -1;
RateConvert(SampleID);
return SampleID;