diff options
author | Florian Dold <florian.dold@gmail.com> | 2015-09-28 20:45:45 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2015-09-28 20:45:45 +0000 |
commit | 8fb11120e2ac1773d07f5df4e2e299637c752338 (patch) | |
tree | c78eb9f5042a05dc06c0d7ab8e36ffed72a06461 /src/util/common_allocation.c | |
parent | 2b70eeaf2bce2c777198d91c5a8357c2426540a0 (diff) | |
download | gnunet-8fb11120e2ac1773d07f5df4e2e299637c752338.tar.gz gnunet-8fb11120e2ac1773d07f5df4e2e299637c752338.zip |
fix undefined behavior in GNUNET_array_grow
Diffstat (limited to 'src/util/common_allocation.c')
-rw-r--r-- | src/util/common_allocation.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index e398e19ae..cd7175eac 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c | |||
@@ -370,7 +370,8 @@ GNUNET_xgrow_ (void **old, | |||
370 | memset (tmp, 0, size); /* client code should not rely on this, though... */ | 370 | memset (tmp, 0, size); /* client code should not rely on this, though... */ |
371 | if (*oldCount > newCount) | 371 | if (*oldCount > newCount) |
372 | *oldCount = newCount; /* shrink is also allowed! */ | 372 | *oldCount = newCount; /* shrink is also allowed! */ |
373 | memcpy (tmp, *old, elementSize * (*oldCount)); | 373 | if (NULL != *old) |
374 | memcpy (tmp, *old, elementSize * (*oldCount)); | ||
374 | } | 375 | } |
375 | 376 | ||
376 | if (*old != NULL) | 377 | if (*old != NULL) |