From 5fa5252648c2ea68f9304a0397de84c5cd2329b2 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 7 Sep 2010 16:33:17 -0700 Subject: Watch for a few more negative sizes --- OpenAL32/alBuffer.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'OpenAL32') diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c index 81e17c52..983396c0 100644 --- a/OpenAL32/alBuffer.c +++ b/OpenAL32/alBuffer.c @@ -115,7 +115,9 @@ AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers) if(!Context) return; // Check that we are actually generation some Buffers - if(n > 0) + if(n < 0) + alSetError(Context, AL_INVALID_VALUE); + else { ALCdevice *device = Context->Device; ALenum err; @@ -180,7 +182,7 @@ AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *puiBuffers) ALboolean bFailed = AL_FALSE; // Check that all the buffers are valid and can actually be deleted - for (i = 0; i < n; i++) + for(i = 0;i < n;i++) { if(!puiBuffers[i]) continue; @@ -206,9 +208,9 @@ AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *puiBuffers) } // If all the Buffers were valid (and have Reference Counts of 0), then we can delete them - if (!bFailed) + if(!bFailed) { - for (i = 0; i < n; i++) + for(i = 0;i < n;i++) { if((ALBuf=LookupBuffer(device->BufferMap, puiBuffers[i])) != NULL) { @@ -286,7 +288,7 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid data = Context->SampleSource->data + offset; } - if(size < 0) + if(size < 0 || freq < 0) alSetError(Context, AL_INVALID_VALUE); else if(ALBuf->refcount != 0) alSetError(Context, AL_INVALID_VALUE); @@ -1070,7 +1072,7 @@ static ALenum LoadData(ALbuffer *ALBuf, const ALvoid *data, ALsizei size, ALuint assert(NewBytes == 4); assert(NewChannels == OrigChannels); - if ((size%(OrigBytes*OrigChannels)) != 0) + if((size%(OrigBytes*OrigChannels)) != 0) return AL_INVALID_VALUE; // Allocate extra padding samples -- cgit v1.2.3