6431: fix bug when loading invalid opus file r=def- a=Marmare314

Trying to load any invalid opus file crashes the editor.

## Checklist

- [x] 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
- [x] Considered possible null pointers and out of bounds array indexing
- [x] 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 08:12:52 +00:00 committed by GitHub
commit 52217add6d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -676,6 +676,8 @@ int CSound::LoadOpusFromMem(const void *pData, unsigned DataSize, bool FromEdito
return -1;
SampleID = DecodeOpus(SampleID, pData, DataSize);
if(SampleID < 0)
return -1;
RateConvert(SampleID);
return SampleID;