Module: wine Branch: master Commit: aa58bcfec9fc7a917b04c159b1204289ec9eeb3d URL: http://source.winehq.org/git/wine.git/?a=commit;h=aa58bcfec9fc7a917b04c159b1...
Author: Marcus Meissner marcus@jet.franken.de Date: Sat Jul 7 11:52:21 2012 +0200
krnl386.exe16: Do not truncate the strcmp result (Coverity).
---
dlls/krnl386.exe16/kernel.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/dlls/krnl386.exe16/kernel.c b/dlls/krnl386.exe16/kernel.c index a1f7fff..e879507 100644 --- a/dlls/krnl386.exe16/kernel.c +++ b/dlls/krnl386.exe16/kernel.c @@ -254,7 +254,14 @@ SEGPTR WINAPI KERNEL_AnsiLower16( SEGPTR strOrChar ) */ INT16 WINAPI KERNEL_lstrcmp16( LPCSTR str1, LPCSTR str2 ) { - return (INT16)strcmp( str1, str2 ); + int ret = strcmp( str1, str2 ); + + /* 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. */ + if (ret < 0) return -1; + if (ret > 0) return 1; + return 0; }
/***********************************************************************