twn_text.c: discard empty inputs
This commit is contained in:
parent
4c49366c44
commit
ac74f39c03
@ -253,6 +253,9 @@ void draw_text(const char *string, Vec2 position, int height_px, Color color, co
|
|||||||
|
|
||||||
/* the original string might not be around by the time it's used, so copy it */
|
/* the original string might not be around by the time it's used, so copy it */
|
||||||
size_t str_length = SDL_strlen(string) + 1;
|
size_t str_length = SDL_strlen(string) + 1;
|
||||||
|
if (str_length == 1)
|
||||||
|
/* empty string */
|
||||||
|
return;
|
||||||
char *dup_string = string_arena_alloc(&string_arena, str_length);
|
char *dup_string = string_arena_alloc(&string_arena, str_length);
|
||||||
SDL_strlcpy(dup_string, string, str_length);
|
SDL_strlcpy(dup_string, string, str_length);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user