Fix improper null termination when stripping clipboard text

This commit is contained in:
Cameron Gutman 2021-12-10 02:04:19 -06:00
parent f2bcb49478
commit 0870dd15a8

View File

@ -107,7 +107,9 @@ void SdlInputHandler::performSpecialKeyCombo(KeyCombo combo)
// each newline in the source, so we fix up any CRLFs into just a single LF. // each newline in the source, so we fix up any CRLFs into just a single LF.
for (char* c = text; *c != 0; c++) { for (char* c = text; *c != 0; c++) {
if (*c == '\r' && *(c + 1) == '\n') { if (*c == '\r' && *(c + 1) == '\n') {
memmove(c, c + 1, strlen(c) - 1); // We're using strlen() rather than strlen() - 1 since we need to add 1
// to copy the null terminator which is not included in strlen()'s count.
memmove(c, c + 1, strlen(c));
} }
} }