diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-07-19 00:33:59 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-07-19 00:33:59 +0000 |
commit | 2ce77adffcc4a54956eaa524ddf0afc1210b30b2 (patch) | |
tree | 065279fc9a015bb54af92c802595c1242135331f /win32 | |
parent | da0838f1870c5338e6bf9ab745ef01fde1406476 (diff) | |
download | perl-2ce77adffcc4a54956eaa524ddf0afc1210b30b2.tar.gz |
avoid bug in win32_str_os_error() (from Jan Dubois)
p4raw-id: //depot/perl@3699
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)*/); |