Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed some off-by-one nonsense.
  • Loading branch information
icculus committed Feb 17, 2009
1 parent 7d4b76d commit c6dca7e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions mojoshader_preprocessor.c
Expand Up @@ -870,9 +870,9 @@ static void handle_pp_define(Context *ctx)
void *d = ctx->malloc_data;
const char space = ' ';
unsigned int len = ((unsigned int) (state->source-state->token));
char *sym = (char *) alloca(len);
memcpy(sym, state->token, len-1);
sym[len-1] = '\0';
char *sym = (char *) alloca(len+1);
memcpy(sym, state->token, len);
sym[len] = '\0';

Buffer buffer;
init_buffer(&buffer);
Expand Down Expand Up @@ -939,9 +939,9 @@ static void handle_pp_undef(Context *ctx)
} // if

const unsigned int len = ((unsigned int) (state->source-state->token));
char *sym = (char *) alloca(len);
memcpy(sym, state->token, len-1);
sym[len-1] = '\0';
char *sym = (char *) alloca(len+1);
memcpy(sym, state->token, len);
sym[len] = '\0';

if (!require_newline(state))
{
Expand All @@ -966,9 +966,9 @@ static Conditional *_handle_pp_ifdef(Context *ctx, const Token type)
} // if

const unsigned int len = ((unsigned int) (state->source-state->token));
char *sym = (char *) alloca(len);
memcpy(sym, state->token, len-1);
sym[len-1] = '\0';
char *sym = (char *) alloca(len+1);
memcpy(sym, state->token, len);
sym[len] = '\0';

if (!require_newline(state))
{
Expand Down

0 comments on commit c6dca7e

Please sign in to comment.