diff options
author | Werner Koch <wk@gnupg.org> | 2003-11-14 11:45:54 +0000 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2003-11-14 11:45:54 +0000 |
commit | 0492e32a432347cd929b9c482e11c2167ae04cb4 (patch) | |
tree | 1326af5626746994e0e2b7f7d94e64ba5911cabe /src/global.c | |
parent | f6f2462012cf4e979487bb2ccce8a7f1ba96d3a7 (diff) | |
download | libgcrypt-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.c | 6 |
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; } |