about summary refs log tree commit diff
path: root/src/libexpr
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2018-03-15T03·44-0400
committerShea Levy <shea@shealevy.com>2018-03-15T03·44-0400
commite2088febf3d0cb1138491c891b134887636e4220 (patch)
treec060b82d5cdcd69b652aaf0cc2e3dbfeac555241 /src/libexpr
parent55aa622fb1ae01a8a939fa32f71e7eed50afbbf9 (diff)
concatLists: Don't pass NULL pointers to memcpy.
This is UB, even if the size is 0. See #1976.

Fixes #1976.
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index f94c23ea72bb..37b977736e28 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;
     }
 }