Marcus Meissner : user.exe: Avoid truncating strcmp result (Coverity).
Alexandre Julliard
julliard at winehq.org
Mon Jul 9 14:56:37 CDT 2012
Module: wine
Branch: master
Commit: f917cd0e42642aefc8924379f4dacacb6563bc24
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f917cd0e42642aefc8924379f4dacacb6563bc24
Author: Marcus Meissner <marcus at jet.franken.de>
Date: Sat Jul 7 11:52:24 2012 +0200
user.exe: Avoid truncating strcmp result (Coverity).
---
dlls/user.exe16/user.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/dlls/user.exe16/user.c b/dlls/user.exe16/user.c
index 705620b..7f184a2 100644
--- a/dlls/user.exe16/user.c
+++ b/dlls/user.exe16/user.c
@@ -2557,7 +2557,14 @@ INT16 WINAPIV wsprintf16( LPSTR buffer, LPCSTR spec, VA_LIST16 valist )
*/
INT16 WINAPI lstrcmp16( LPCSTR str1, LPCSTR str2 )
{
- return strcmp( str1, str2 );
+ int ret;
+ /* Looks too complicated, but in optimized strcpy we might get
+ * a 32bit wide difference and would truncate it to 16 bit, so
+ * erroneously returning equality. */
+ ret = strcmp( str1, str2 );
+ if (ret < 0) return -1;
+ if (ret > 0) return 1;
+ return 0;
}
More information about the wine-cvs
mailing list