Skip to content

Commit c11476e

Browse files
urshanselmannflibitijibibo
authored andcommitted
Add missing null-terminator on file macro definition string
1 parent 6c90330 commit c11476e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

mojoshader_preprocessor.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,12 +451,13 @@ static const Define *find_define(Context *ctx, const char *sym)
451451
const IncludeState *state = ctx->include_stack;
452452
const char *fname = state ? state->filename : "";
453453
const size_t len = strlen(fname) + 2;
454-
char *str = (char *) Malloc(ctx, len);
454+
char *str = (char *) Malloc(ctx, len + 1);
455455
if (!str)
456456
return NULL;
457457
str[0] = '\"';
458458
memcpy(str + 1, fname, len - 2);
459459
str[len - 1] = '\"';
460+
str[len] = '\0';
460461
ctx->file_macro->definition = str;
461462
return ctx->file_macro;
462463
} // if

0 commit comments

Comments
 (0)