Skip to content

garray: Avoid calling memcpy with no items

Simon McVittie requested to merge wip/smcv/gptrarray-memcpy-nothing into main

memcpy(NULL, ., n) and memcpy(., NULL, n) are undefined behaviour, even if n is zero.

When len is 0 here, callers are allowed to pass in null data, and GPtrArray also does not guarantee to have allocated rarray->pdata yet.


Noticed while fixing up !3190 (merged).

/cc @ @3v1n0

Edited by Simon McVittie

Merge request reports