diff options
author | René Scharfe <l.s.r@web.de> | 2016-10-15 18:23:11 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-10-17 14:42:31 -0700 |
commit | e9451782cfbe9fc9105bf63228bca3e2265af8f8 (patch) | |
tree | 273fb9ec943e2d478f61011b8a92c93d01d3b504 /builtin/ls-tree.c | |
parent | receive-pack: use FLEX_ALLOC_MEM in queue_command() (diff) | |
download | tgif-e9451782cfbe9fc9105bf63228bca3e2265af8f8.tar.xz |
avoid pointer arithmetic involving NULL in FLEX_ALLOC_MEM
Calculating offsets involving a NULL pointer is undefined. It works in
practice (for now?), but we should not rely on it. Allocate first and
then simply refer to the flexible array member by its name instead of
performing pointer arithmetic up front. The resulting code is slightly
shorter, easier to read and doesn't rely on undefined behaviour.
NB: The cast to a (non-const) void pointer is necessary to keep support
for flexible array members declared as const.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/ls-tree.c')
0 files changed, 0 insertions, 0 deletions