[PATCH] Check for null pointers given to memcpy with ubsan
Richard Smith
richard at metafoo.co.uk
Sun May 24 09:43:46 PDT 2015
I agree that we should be respecting the `__attribute__((nonnull))` on these functions whether or not we emit them as builtin calls; as such, it makes sense to me for this to be under `-fsanitize=nonnull-attribute`. A couple of minor copy-paste issues and then this looks fine to me, but please wait to make sure that @samsonov is persuaded.
REPOSITORY
rL LLVM
================
Comment at: lib/CodeGen/CGBuiltin.cpp:715
@@ -712,1 +714,3 @@
+ EmitNonNullArgCheck(RValue::get(Src.first), E->getArg(1)->getType(),
+ E->getArg(1)->getExprLoc(), FD, 0);
Builder.CreateMemCpy(Dest.first, Src.first, SizeVal, Align, false);
----------------
The `0` here should be a `1`.
================
Comment at: lib/CodeGen/CGBuiltin.cpp:776
@@ -769,1 +775,3 @@
+ EmitNonNullArgCheck(RValue::get(Src.first), E->getArg(1)->getType(),
+ E->getArg(1)->getExprLoc(), FD, 0);
Builder.CreateMemMove(Dest.first, Src.first, SizeVal, Align, false);
----------------
Likewise.
http://reviews.llvm.org/D9673
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list