[Swan-dev] memory: in clone_bytes() don't call memcpy(,,0)
D. Hugh Redelmeier
hugh at mimosa.com
Fri Sep 2 01:51:25 EEST 2022
| From: Andrew Cagney <cagney at vault.libreswan.fi>
| New commits:
| commit ba30451878021e304e510cfc3adc1493bd41a31d
| Author: Andrew Cagney <cagney at gnu.org>
| Date: Thu Sep 1 14:24:46 2022 -0400
| memory: in clone_bytes() don't call memcpy(,,0)
| undefined; fix github #836
I don't understand this change. It prevents calling memcpy when
the size would be 0.
It is perfectly legal to call memcpy with a size of 0.
What's slightly surprising is that the C standard requires that the source
and destination pointers must not have invalid values even when the size
is 0. NULL is an invalid value (but the code prevents that). Beyond
that, the standard isn't clear what an invalid value is.
Before this change, did we call memcpy with an invalid value? For the
source? For the destination?
More information about the Swan-dev