diff options
author | Shea Levy <shea@shealevy.com> | 2018-03-14 23:44:02 -0400 |
---|---|---|
committer | Shea Levy <shea@shealevy.com> | 2018-03-14 23:44:02 -0400 |
commit | e2088febf3d0cb1138491c891b134887636e4220 (patch) | |
tree | c060b82d5cdcd69b652aaf0cc2e3dbfeac555241 | |
parent | 55aa622fb1ae01a8a939fa32f71e7eed50afbbf9 (diff) |
concatLists: Don't pass NULL pointers to memcpy.
This is UB, even if the size is 0. See #1976.
Fixes #1976.
-rw-r--r-- | src/libexpr/eval.cc | 3 |
1 files changed, 2 insertions, 1 deletions
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; } } |