From 305cbdf7425e58226953fb73c2cff809a74de9a1 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 4 Dec 2023 21:12:59 -0800 Subject: Check for a valid alignment with callback buffers --- al/buffer.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'al/buffer.cpp') diff --git a/al/buffer.cpp b/al/buffer.cpp index ae41585f..e577e17a 100644 --- a/al/buffer.cpp +++ b/al/buffer.cpp @@ -402,6 +402,10 @@ void PrepareCallback(ALCcontext *context, ALbuffer *ALBuf, ALsizei freq, const ALuint unpackalign{ALBuf->UnpackAlign}; const ALuint align{SanitizeAlignment(DstType, unpackalign)}; + if(align < 1) UNLIKELY + return context->setError(AL_INVALID_VALUE, "Invalid unpack alignment %u for %s samples", + unpackalign, NameFromFormat(DstType)); + const ALuint BlockSize{ChannelsFromFmt(DstChannels, ambiorder) * ((DstType == FmtIMA4) ? (align-1)/2 + 4 : (DstType == FmtMSADPCM) ? (align-2)/2 + 7 : -- cgit v1.2.3