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';