Skip to content

Commit

Permalink
Fixed assertion failure when defining a void-argument macro: "#define…
Browse files Browse the repository at this point in the history
… a() b"
  • Loading branch information
icculus committed Apr 9, 2009
1 parent 363eac9 commit 8d392c7
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions mojoshader_preprocessor.c
Expand Up @@ -997,9 +997,12 @@ static void handle_pp_define(Context *ctx)
goto handle_pp_define_failed;
} // if

idents = (char **) Malloc(ctx, sizeof (char *) * params);
if (idents == NULL)
goto handle_pp_define_failed;
if (params > 0)
{
idents = (char **) Malloc(ctx, sizeof (char *) * params);
if (idents == NULL)
goto handle_pp_define_failed;
} // if

// roll all the way back, do it again.
memcpy(state, &saved, sizeof (IncludeState));
Expand All @@ -1018,8 +1021,11 @@ static void handle_pp_define(Context *ctx)
dst[state->tokenlen] = '\0';
idents[i] = dst;

lexer(state);
assert( (state->tokenval == ((Token) ')')) || (state->tokenval == ((Token) ',')) );
if (i < (params-1))
{
lexer(state);
assert(state->tokenval == ((Token) ','));
} // if
} // for

if (i != params)
Expand All @@ -1028,6 +1034,7 @@ static void handle_pp_define(Context *ctx)
goto handle_pp_define_failed;
} // if

lexer(state);
assert(state->tokenval == ((Token) ')'));
lexer(state);
} // else if
Expand Down Expand Up @@ -1082,6 +1089,7 @@ static void handle_pp_define(Context *ctx)
goto handle_pp_define_failed;

assert(done);

if (!add_define(ctx, sym, definition, idents, params))
goto handle_pp_define_failed;

Expand Down

0 comments on commit 8d392c7

Please sign in to comment.