diff options
author | Justus Winter <[email protected]> | 2015-11-19 10:21:21 +0000 |
---|---|---|
committer | Justus Winter <[email protected]> | 2015-11-19 10:27:44 +0000 |
commit | 06af687beaa1f8e72a05bd3a057b73fecb158c3d (patch) | |
tree | d485743c10f031443840997b2a539bbc7bb12269 | |
parent | Add error codes NO_NAME, NO_KEY, and SERVER_FAILURE. (diff) | |
download | libgpg-error-06af687beaa1f8e72a05bd3a057b73fecb158c3d.tar.gz libgpg-error-06af687beaa1f8e72a05bd3a057b73fecb158c3d.zip |
Avoid 'malloc' corner case.
* src/init.c (_gpgrt_realloc): Avoid calling 'malloc(0)'.
--
Previously, if '_gpgrt_realloc' was called with both A and N being
zero, malloc is invoked with a size of zero. This happens e.g. when
calling '_gpgrt_free' with a NULL pointer, which is supposed to be a
no-op.
Found using the Clang Static Analyzer.
Signed-off-by: Justus Winter <[email protected]>
-rw-r--r-- | src/init.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -171,15 +171,15 @@ _gpgrt_realloc (void *a, size_t n) if (custom_realloc) return custom_realloc (a, n); - if (!a) - return malloc (n); - if (!n) { free (a); return NULL; } + if (!a) + return malloc (n); + return realloc (a, n); } |