Skip to content

[raudio] Check input data before loading Wave or Music from memory - #6324

Merged
raysan5 merged 1 commit into
raysan5:masterfrom
akashdeshmukh-git:raudio-check-input-data
Oct 24, 2026
Merged

raysan5 merged 1 commit into
raysan5:masterfrom
akashdeshmukh-git:raudio-check-input-data

Conversation

@akashdeshmukh-git

Copy link
Copy Markdown
Contributor

What was wrong

LoadWaveFromMemory() did not check fileData for NULL or dataSize <= 0, passing invalid pointers directly into underlying decoders (drwav_init_memory, stb_vorbis_open_memory, etc.).
LoadMusicStreamFromMemory() did not check fileType for NULL, causing a segmentation fault in strcmp() when an extension is missing, nor did it check data for NULL or dataSize <= 0.

How to reproduce

Call LoadMusicStreamFromMemory(NULL, ...) to trigger a crash in strcmp(), or call LoadWaveFromMemory(".wav", NULL, 0) with a NULL buffer.

What changed

Added security checks in LoadWaveFromMemory() and LoadMusicStreamFromMemory() to validate fileType, fileData / data, and dataSize > 0 before attempting to decode, matching the existing checks in LoadImageFromMemory().

How it was tested

Verified with test calls passing NULL buffers and NULL fileType extensions; both functions now log a warning and return empty structs instead of crashing or invoking decoders on invalid memory. Built examples cleanly with GCC.

@raysan5
raysan5 merged commit eb8cb1b into raysan5:master Oct 24, 2026
16 checks passed
@raysan5

raysan5 commented Oct 24, 2026

Copy link
Copy Markdown
Owner

@akashdeshmukh-git thanks for the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants