From 954d202637b582d93e3db9c022228fc1524064af Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Sun, 20 Jul 2025 03:14:20 +0200 Subject: [PATCH] string_remove_all_chars - only write if the character is not the one to remove --- libretro-common/string/stdstring.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libretro-common/string/stdstring.c b/libretro-common/string/stdstring.c index e925adadaf..754a8d2cf0 100644 --- a/libretro-common/string/stdstring.c +++ b/libretro-common/string/stdstring.c @@ -495,9 +495,10 @@ void string_remove_all_chars(char *s, char c) while (*read_ptr != '\0') { - *write_ptr = *read_ptr++; - if (*write_ptr != c) - write_ptr++; + /* Only write if the character is not the one to remove */ + if (*read_ptr != c) + *write_ptr++ = *read_ptr; + read_ptr++; } *write_ptr = '\0';