concatLists: Don't pass NULL pointers to memcpy.

This is UB, even if the size is 0. See #1976.

Fixes #1976.
This commit is contained in:
Shea Levy 2018-03-14 23:44:02 -04:00
parent 55aa622fb1
commit e2088febf3
No known key found for this signature in database
GPG key ID: 5C0BD6957D86FE27

View file

@ -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;
}
}