From e2088febf3d0cb1138491c891b134887636e4220 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 14 Mar 2018 23:44:02 -0400 Subject: [PATCH] concatLists: Don't pass NULL pointers to memcpy. This is UB, even if the size is 0. See #1976. Fixes #1976. --- src/libexpr/eval.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index f94c23ea7..37b977736 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -1316,7 +1316,8 @@ void EvalState::concatLists(Value & v, unsigned int nrLists, Value * * lists, co auto out = v.listElems(); for (unsigned int n = 0, pos = 0; n < nrLists; ++n) { unsigned int l = lists[n]->listSize(); - memcpy(out + pos, lists[n]->listElems(), l * sizeof(Value *)); + if (l) + memcpy(out + pos, lists[n]->listElems(), l * sizeof(Value *)); pos += l; } }