| Summary: | Segfault when passing NULL as extension to Sound_NewSample | ||
|---|---|---|---|
| Product: | SDL_sound | Reporter: | SuperZazu <nico.g.allemand> |
| Component: | everything | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Ryan C. Gordon <icculus> |
| Severity: | normal | ||
| Priority: | P2 | CC: | sezeroz |
| Version: | unspecified | ||
| Hardware: | x86 | ||
| OS: | macOS 10.13 | ||
I fixed it differently here: https://github.com/sezero/SDL_sound/commit/3e7c880b27360d3bc87fd3560f173b5651aad3ce Indeed, I noticed that your repo included a fix for this after creating my post, thanks for your work! The issue is fixed in mainstream as of https://hg.icculus.org/icculus/SDL_sound/rev/5f2d5eeb97e6 Closing. |
Hello! I just noticed a segfault when passing NULL to Sound_NewSample. Note that it does not happen when passing "". To reproduce the bug quickly, you can modify "playsound_simple.c" like this: ``` diff -r 4c3740db6ea6 playsound/playsound_simple.c --- a/playsound/playsound_simple.c Sat Feb 09 11:38:38 2019 +0100 +++ b/playsound/playsound_simple.c Sat Feb 09 12:07:31 2019 +0100 @@ -99,7 +99,9 @@ PlaysoundAudioCallbackData data; SDL_zero(data); - data.sample = Sound_NewSampleFromFile(fname, NULL, 65536); + // segfault does happen when ext == NULL; and does not happen when ext == "" + const char* ext = NULL; + data.sample = Sound_NewSample(SDL_RWFromFile(fname, "rb"), ext, NULL, 65536); if (data.sample == NULL) { fprintf(stderr, "Couldn't load '%s': %s.\n", fname, Sound_GetError()); ``` Here is a patch that fixes the problem: ``` diff -r 9262f9205898 -r 4c3740db6ea6 src/SDL_sound.c --- a/src/SDL_sound.c Fri Jul 20 14:59:10 2018 -0400 +++ b/src/SDL_sound.c Sat Feb 09 11:38:38 2019 +0100 @@ -506,6 +506,9 @@ } /* for */ } /* if */ + if (ext == NULL) + ext = ""; + /* no direct extension match? Try everything we've got... */ for (decoder = &decoders[0]; decoder->funcs != NULL; decoder++) { ``` As a side note, is there any simpler way to propose patches directly to the mercurial repository? Thank you for your time