[PATCH v2 2/3] winex11.drv: avoid passing NULL to memcpy (clang)

Kirill Smirnov kirill.k.smirnov at gmail.com
Fri Jul 8 02:12:24 CDT 2016


According to the standard, memcpy() and its friends
should never accept NULL as argument, otherwise
the behavior is undefined and optimizer takes this
into account.

Below in the same file (line 206) caller passes
NULL as lpComp argument triggering this case.

This patch is of the same nature as the following:

commit 5a3ad0ecf08c00fc0b7b2f24e55be27b7c3f5da0
Author: Kirill Smirnov <kirill.k.smirnov at gmail.com>
Date:   Mon May 9 18:56:14 2016 +0300

     winhlp32: Do not pass NULL to strchr() (spotted by clang).

     Signed-off-by: Kirill K. Smirnov <kirill.k.smirnov at gmail.com>
     Signed-off-by: Alexandre Julliard <julliard at winehq.org>



On 08.07.2016 06:16, Alexandre Julliard wrote:
> Kirill Smirnov <kirill.k.smirnov at gmail.com> writes:
>
>> @@ -92,7 +92,8 @@ static void X11DRV_ImmSetInternalString(DWORD dwOffset,
>>      ptr_new = CompositionString + byte_offset;
>>      memmove(ptr_new + byte_length, ptr_new + byte_selection,
>>              dwCompStringLength - byte_offset - byte_selection);
>> -    memcpy(ptr_new, lpComp, byte_length);
>> +    /* Do not pass NULL even if the length == 0 */
>> +    if (lpComp) memcpy(ptr_new, lpComp, byte_length);
>>      dwCompStringLength += byte_expansion;
>
> Why would that be a problem?
>



More information about the wine-devel mailing list