diff options
author | Werner Koch <wk@gnupg.org> | 2011-04-01 10:16:31 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2011-04-01 10:16:31 +0200 |
commit | 934d270ff8193a5931b143ce850f66f50d03dedf (patch) | |
tree | bf80b5ebadafa34805e1323ca67f50001fa4ea67 /src/global.c | |
parent | ec033383618c4b3739783d31ca4dc70c9bb4fcfe (diff) | |
download | libgcrypt-934d270ff8193a5931b143ce850f66f50d03dedf.tar.gz |
Make sure that gcry_realloc (NULL, n) works on all platforms.
realloc (NULL, n) shall behave exactly like malloc (n)
and realloc (p, 0) like free.
Not all platforms implement this correctly thus we now handle this
directly in gcry_realloc.
Diffstat (limited to 'src/global.c')
-rw-r--r-- | src/global.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/global.c b/src/global.c index cbb7eb89..d65b0680 100644 --- a/src/global.c +++ b/src/global.c @@ -833,6 +833,16 @@ gcry_realloc (void *a, size_t n) { void *p; + /* To avoid problems with non-standard realloc implementations and + our own secmem_realloc, we divert to malloc and free here. */ + if (!a) + return gcry_malloc (n); + if (!n) + { + gcry_free (a); + return NULL; + } + if (realloc_func) p = realloc_func (a, n); else |