UBSAN warnings on calls to memcpy

Andreas Schneider asn at samba.org
Thu May 23 05:46:11 UTC 2019


On Thursday, 23 May 2019 05:20:40 CEST Gary Lockyer via samba-technical wrote:
> One of the more common UBSAN errors is
> "null pointer passed as argument 2, which is declared to never be null"

Hi Gary,
 
> These are calls to memcpy where the source length is 0, and the data is
> NULL. Adding an "if (length > 0) {" guard before the memcpy would fix
> the warning.
> 
> I'm inclined to think we should do this, but also agree that it does
> clutter the code. While the call to memcpy should be safe, removing the
> warnings reduces the clutter and makes it less likely we'll miss a real
> issue.

I think we should fix those. There will be other tools (csbuild) also 
complaining about them ...

I would guess that an optimizer could remove that if not needed.


	Andreas





More information about the samba-technical mailing list