Skip to content

Commit

Permalink
Fix handling of NULL args to various listener state calls.
Browse files Browse the repository at this point in the history
The Gets should be legal no-ops, the Sets should generate errors.
  • Loading branch information
icculus committed Apr 17, 2018
1 parent 3e2ace6 commit c1e20ab
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions mojoal.c
Expand Up @@ -2149,14 +2149,16 @@ void alListener3f(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3)

void alListenerfv(ALenum param, const ALfloat *values)
{
ALfloat dummy[6];
ALCcontext *ctx = get_current_context();
if (!ctx) {
set_al_error(ctx, AL_INVALID_OPERATION);
return;
}

if (!values) values = dummy;
if (!values) {
set_al_error(ctx, AL_INVALID_VALUE);
return;
}

switch (param) {
case AL_GAIN:
Expand Down Expand Up @@ -2203,14 +2205,16 @@ void alListener3i(ALenum param, ALint value1, ALint value2, ALint value3)

void alListeneriv(ALenum param, const ALint *values)
{
ALint dummy[6];
ALCcontext *ctx = get_current_context();
if (!ctx) {
set_al_error(ctx, AL_INVALID_OPERATION);
return;
}

if (!values) values = dummy;
if (!values) {
set_al_error(ctx, AL_INVALID_VALUE);
return;
}

switch (param) {
case AL_POSITION:
Expand Down Expand Up @@ -2272,14 +2276,13 @@ void alGetListener3f(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *va

void alGetListenerfv(ALenum param, ALfloat *values)
{
ALfloat dummy[6];
ALCcontext *ctx = get_current_context();
if (!ctx) {
set_al_error(ctx, AL_INVALID_OPERATION);
return;
}

if (!values) values = dummy;
if (!values) return; /* legal no-op */

switch (param) {
case AL_GAIN:
Expand Down Expand Up @@ -2329,14 +2332,13 @@ void alGetListener3i(ALenum param, ALint *value1, ALint *value2, ALint *value3)

void alGetListeneriv(ALenum param, ALint *values)
{
ALint dummy[6];
ALCcontext *ctx = get_current_context();
if (!ctx) {
set_al_error(ctx, AL_INVALID_OPERATION);
return;
}

if (!values) values = dummy;
if (!values) return; /* legal no-op */

switch (param) {
case AL_POSITION:
Expand Down

0 comments on commit c1e20ab

Please sign in to comment.