twn_text.c: discard empty inputs

This commit is contained in:
veclav talica 2024-10-07 23:40:57 +03:00
parent 4c49366c44
commit ac74f39c03

View File

@ -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 */
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);
SDL_strlcpy(dup_string, string, str_length);