summaryrefslogtreecommitdiff
path: root/src/global.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2003-11-14 11:45:54 +0000
committerWerner Koch <wk@gnupg.org>2003-11-14 11:45:54 +0000
commit0492e32a432347cd929b9c482e11c2167ae04cb4 (patch)
tree1326af5626746994e0e2b7f7d94e64ba5911cabe /src/global.c
parentf6f2462012cf4e979487bb2ccce8a7f1ba96d3a7 (diff)
downloadlibgcrypt-0492e32a432347cd929b9c482e11c2167ae04cb4.tar.gz
(gcry_strdup): Don't copy the string after a malloc
error.
Diffstat (limited to 'src/global.c')
-rw-r--r--src/global.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/global.c b/src/global.c
index 02a67679..56d81145 100644
--- a/src/global.c
+++ b/src/global.c
@@ -494,7 +494,8 @@ gcry_calloc_secure (size_t n, size_t m)
size_t bytes;
void *p;
- bytes = n * m; /* size_t is unsigned so the behavior on overflow is defined. */
+ bytes = n * m; /* size_t is unsigned so the behavior on overflow is
+ defined. */
if (m && bytes / m != n)
{
errno = ENOMEM;
@@ -512,7 +513,8 @@ char *
gcry_strdup( const char *string )
{
void *p = gcry_malloc( strlen(string)+1 );
- strcpy( p, string );
+ if (p)
+ strcpy (p, string);
return p;
}