Skip to content

Commit

Permalink
mkfont: make bmfont parser more resistant
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky committed Jun 24, 2024
1 parent 4d245dd commit 29c5a64
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions tools/mkfont/mkfont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void print_args( char * name )
fprintf(stderr, " glyphs in the font.\n");
fprintf(stderr, " --monochrome Force monochrome output, with no aliasing (default: off)\n");
fprintf(stderr, " --outline <width> Add outline to font, specifying its width in (fractional) pixels\n");
fprintf(stderr, "\n");
fprintf(stderr, "BMFont specific flags:\n");
fprintf(stderr, " --format <format> Specify the output texture format. Valid options are:\n");
fprintf(stderr, " RGBA16, RGBA32, CI4, CI8 (default: RGBA16)\n");
Expand Down
4 changes: 3 additions & 1 deletion tools/mkfont/mkfont_bmfont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ char* tokenize_bmfont_line(char *line_in)
line += strspn(line, " \t\r\n");
if (!*line) return NULL;
char *key = line;
line += strcspn(line, "="); *line++ = '\0';
line += strcspn(line, "=");
if (!*line) return NULL; // ignore keys without value
*line++ = '\0';
return key;
} else {
line += strspn(line, " \t\r\n");
Expand Down

0 comments on commit 29c5a64

Please sign in to comment.