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

Alexandre Julliard julliard at winehq.org
Sat Jul 9 01:42:05 CDT 2016


Kirill Smirnov <kirill.k.smirnov at gmail.com> writes:

> 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).

strchr has to access the pointer so obviously it can't take NULL, but
memcpy with a zero length shouldn't, so it's not very useful compiler
behavior IMO. Sadly it seems the standard does allow it...

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list