aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2012-12-13 19:29:46 +0100
committerAndreas Schneider <asn@cryptomilk.org>2012-12-13 19:29:46 +0100
commitde9bc1fa41155f30257b73a8bc8b55ce496fbb62 (patch)
treeafd411a8c31fb181737fbfd946bb75ae5621d276
parentb14df297fa72a9c40a6548b11e70185877abe0de (diff)
downloadlibssh-de9bc1fa41155f30257b73a8bc8b55ce496fbb62.tar.gz
libssh-de9bc1fa41155f30257b73a8bc8b55ce496fbb62.tar.xz
libssh-de9bc1fa41155f30257b73a8bc8b55ce496fbb62.zip
string: Fix memory leak in ssh_string_to_char().
This was probably a mistake by me fixing up a patch after merging.
-rw-r--r--src/string.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/string.c b/src/string.c
index acaa41af..5ef90b0e 100644
--- a/src/string.c
+++ b/src/string.c
@@ -167,12 +167,12 @@ const char *ssh_string_get_char(struct ssh_string_struct *s)
* string may not be readable with regular libc functions.
*/
char *ssh_string_to_char(struct ssh_string_struct *s) {
- size_t len;
- char *new;
- if (s == NULL)
- return NULL;
- len = ssh_string_len(s) + 1;
- new = malloc(len);
+ size_t len;
+ char *new;
+
+ if (s == NULL) {
+ return NULL;
+ }
len = ssh_string_len(s);
if (len + 1 < len) {