Author: Richard Smith Date: 2020-12-15T14:37:52-08:00 New Revision: c4736b91f87e9163edcdef78891398f32390ffc2
URL: https://github.com/llvm/llvm-project/commit/c4736b91f87e9163edcdef78891398f32390ffc2 DIFF: https://github.com/llvm/llvm-project/commit/c4736b91f87e9163edcdef78891398f32390ffc2.diff LOG: Don't memcpy from an empty ArrayRef; the base pointer could be null, and the C rules say memcpy can't accept a null pointer. This should fix a test failure with the ubsan buildbots. Added: Modified: clang/lib/AST/APValue.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp index 5b340e6e85bd..c18f8854dc2b 100644 --- a/clang/lib/AST/APValue.cpp +++ b/clang/lib/AST/APValue.cpp @@ -952,8 +952,10 @@ void APValue::setLValue(LValueBase B, const CharUnits &O, bool IsNullPtr) { MutableArrayRef<APValue::LValuePathEntry> InternalPath = setLValueUninit(B, O, Path.size(), IsOnePastTheEnd, IsNullPtr); - memcpy(InternalPath.data(), Path.data(), - Path.size() * sizeof(LValuePathEntry)); + if (Path.size()) { + memcpy(InternalPath.data(), Path.data(), + Path.size() * sizeof(LValuePathEntry)); + } } void APValue::setUnion(const FieldDecl *Field, const APValue &Value) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits