Skip to content
Snippets Groups Projects
Commit 3af08f89 authored by Niklas Haas's avatar Niklas Haas
Browse files

talloc: don't trigger undefined behavior in TARRAY_CONCAT

Concatenating 0 elements from NULL to any other array is fine. So don't
call memmove() with src=NULL, even if the size is 0, since this triggers
ubsan.
parent 9edd5911
No related merge requests found
......@@ -159,9 +159,11 @@ bool xta_ref_attach(void *t, struct xta_ref *ref);
#define TARRAY_CONCAT(ctx, p, idxvar, op, oidxvar) \
do { \
TARRAY_GROW(ctx, p, (idxvar) + (oidxvar)); \
memmove((p) + (idxvar), (op), \
(oidxvar) * sizeof((op)[0])); \
(idxvar) += (oidxvar); \
if ((oidxvar)) { \
memmove((p) + (idxvar), (op), \
(oidxvar) * sizeof((op)[0])); \
(idxvar) += (oidxvar); \
} \
} while (0)
// Doesn't actually free any memory, or do any other talloc calls.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment