Frédéric Delanoy : msvcrt: Avoid potential integer overflow when computing median position in bsearch.
Module: wine Branch: master Commit: b9e306ee78ee4bb7ee51b8ffc3cf7a54ed00a2e9 URL: http://source.winehq.org/git/wine.git/?a=commit;h=b9e306ee78ee4bb7ee51b8ffc3... Author: Frédéric Delanoy <frederic.delanoy(a)gmail.com> Date: Sun Jun 29 12:05:36 2014 +0200 msvcrt: Avoid potential integer overflow when computing median position in bsearch. --- dlls/msvcrt/misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/msvcrt/misc.c b/dlls/msvcrt/misc.c index d791699..fc5a5a9 100644 --- a/dlls/msvcrt/misc.c +++ b/dlls/msvcrt/misc.c @@ -139,7 +139,7 @@ void* CDECL MSVCRT_bsearch_s(const void *key, const void *base, while (min <= max) { - ssize_t cursor = (min + max) / 2; + ssize_t cursor = min + (max - min) / 2; int ret = compare(ctx, key,(const char *)base+(cursor*size)); if (!ret) return (char*)base+(cursor*size);
participants (1)
-
Alexandre Julliard