From b1a3f4ee33a300ae446eccb024f472e54ac9361a Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 4 May 2015 16:21:04 +0200 Subject: pki_container: Fix a memory leak CID: #1267980 Signed-off-by: Andreas Schneider --- src/pki_container_openssh.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pki_container_openssh.c b/src/pki_container_openssh.c index c276f486..bfc6f8d4 100644 --- a/src/pki_container_openssh.c +++ b/src/pki_container_openssh.c @@ -613,9 +613,16 @@ ssh_string ssh_pki_openssh_privkey_export(const ssh_key privkey, } if (to_encrypt){ - ssh_buffer kdf_buf = ssh_buffer_new(); + ssh_buffer kdf_buf; + + kdf_buf = ssh_buffer_new(); + if (kdf_buf == NULL) { + goto error; + } + salt = ssh_string_new(16); - if (kdf_buf == NULL || salt == NULL){ + if (salt == NULL){ + ssh_buffer_free(kdf_buf); goto error; } ssh_get_random(ssh_string_data(salt),16, 0); -- cgit