summaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-05-24 03:20:14 -0700
committerChris Robinson <[email protected]>2010-05-24 03:20:14 -0700
commit80a22b648448efe6209cbb9d7b7abdb9147d6bca (patch)
treea678ba1431fbfd4be7f2313adf6e5d362d17c2d6 /OpenAL32
parent8cfac7c6b8b1243e5e77bf2946820c79d18d8997 (diff)
Reorder some error checks and watch for negative buffer sizes
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/alBuffer.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/OpenAL32/alBuffer.c b/OpenAL32/alBuffer.c
index 4a92ba2d..43d1b13e 100644
--- a/OpenAL32/alBuffer.c
+++ b/OpenAL32/alBuffer.c
@@ -268,7 +268,9 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid
if(!Context) return;
device = Context->Device;
- if((ALBuf=LookupBuffer(device->BufferMap, buffer)) != NULL)
+ if((ALBuf=LookupBuffer(device->BufferMap, buffer)) == NULL)
+ alSetError(Context, AL_INVALID_NAME); /* Invalid Buffer Name */
+ else
{
if(Context->SampleSource)
{
@@ -285,7 +287,11 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid
data = Context->SampleSource->data + offset;
}
- if(ALBuf->refcount==0)
+ if(size < 0)
+ alSetError(Context, AL_INVALID_VALUE);
+ else if(ALBuf->refcount != 0)
+ alSetError(Context, AL_INVALID_VALUE);
+ else
{
switch(format)
{
@@ -514,16 +520,6 @@ AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid
break;
}
}
- else
- {
- // Buffer is in use, or data is a NULL pointer
- alSetError(Context, AL_INVALID_VALUE);
- }
- }
- else
- {
- // Invalid Buffer Name
- alSetError(Context, AL_INVALID_NAME);
}
ProcessContext(Context);