[PATCH] dplayx: Check array index limit first.

Huw Davies huw at codeweavers.com
Wed May 16 05:09:19 CDT 2018


On Wed, May 16, 2018 at 12:37:59PM +0300, Andrey Gusev wrote:
> Signed-off-by: Andrey Gusev <andrey.goosev at gmail.com>
> ---
>  dlls/dplayx/dplayx_global.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/dlls/dplayx/dplayx_global.c b/dlls/dplayx/dplayx_global.c
> index 14c53a0c8d..90c3ed8d7e 100644
> --- a/dlls/dplayx/dplayx_global.c
> +++ b/dlls/dplayx/dplayx_global.c
> @@ -120,7 +120,7 @@ static LPVOID DPLAYX_PrivHeapAlloc( DWORD flags, DWORD size )
>  
>    /* Find blank area */
>    uBlockUsed = 0;
> -  while( lpMemArea[ uBlockUsed ].used && uBlockUsed <= dwMaxBlock ) { uBlockUsed++; }
> +  while( uBlockUsed <= dwMaxBlock && lpMemArea[ uBlockUsed ].used ) { uBlockUsed++; }
>  
>    if( uBlockUsed <= dwMaxBlock )
>    {

This almost certainly needs to be uBlockUsed < dwMaxBlock, same with
the if statement below.

Huw.



More information about the wine-devel mailing list