diff options
Diffstat (limited to 'win32')
-rw-r--r-- | win32/win32.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/win32/win32.c b/win32/win32.c index 59e493ab7f..b28b042d66 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -1802,12 +1802,14 @@ win32_str_os_error(void *sv, DWORD dwErr) |FORMAT_MESSAGE_IGNORE_INSERTS |FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr, 0, (char *)&sMsg, 1, NULL); + /* strip trailing whitespace and period */ if (0 < dwLen) { - while (0 < dwLen && isSPACE(sMsg[--dwLen])) - ; + do { + --dwLen; /* dwLen doesn't include trailing null */ + } while (0 < dwLen && isSPACE(sMsg[dwLen])); if ('.' != sMsg[dwLen]) dwLen++; - sMsg[dwLen]= '\0'; + sMsg[dwLen] = '\0'; } if (0 == dwLen) { sMsg = (char*)LocalAlloc(0, 64/**sizeof(TCHAR)*/); |