From 6eef4b4a3c32f01532b241f690e8a276d92c2ca4 Mon Sep 17 00:00:00 2001 From: Anderson Toshiyuki Sasaki Date: Tue, 25 Sep 2018 13:24:27 +0200 Subject: [PATCH] tests: Add frees to avoid memory leak errors The added frees are unnecessary, but the static analyser does not know. Signed-off-by: Anderson Toshiyuki Sasaki Reviewed-by: Andreas Schneider --- tests/unittests/torture_keyfiles.c | 6 ++++++ tests/unittests/torture_pki_dsa.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/tests/unittests/torture_keyfiles.c b/tests/unittests/torture_keyfiles.c index 55af6c7b..59a4f5ee 100644 --- a/tests/unittests/torture_keyfiles.c +++ b/tests/unittests/torture_keyfiles.c @@ -119,11 +119,17 @@ static void torture_pubkey_from_file(void **state) { rc = ssh_try_publickey_from_file(session, LIBSSH_RSA_TESTKEY, &pubkey, &type); assert_true(rc == 1); + /* This free is unnecessary, but the static analyser does not know */ + SSH_STRING_FREE(pubkey); + /* test if it returns -1 if privkey doesn't exist */ unlink(LIBSSH_RSA_TESTKEY); rc = ssh_try_publickey_from_file(session, LIBSSH_RSA_TESTKEY, &pubkey, &type); assert_true(rc == -1); + + /* This free is unnecessary, but the static analyser does not know */ + SSH_STRING_FREE(pubkey); } static int torture_read_one_line(const char *filename, char *buffer, size_t len) { diff --git a/tests/unittests/torture_pki_dsa.c b/tests/unittests/torture_pki_dsa.c index 37348511..41ab9063 100644 --- a/tests/unittests/torture_pki_dsa.c +++ b/tests/unittests/torture_pki_dsa.c @@ -335,6 +335,9 @@ torture_pki_dsa_import_openssh_privkey_base64_passphrase(void **state) &key); assert_true(rc == -1); + /* This free is unnecessary, but the static analyser does not know */ + SSH_KEY_FREE(key); + /* test if it returns -1 if passphrase is NULL */ rc = ssh_pki_import_privkey_base64(keystring, NULL, @@ -342,6 +345,9 @@ torture_pki_dsa_import_openssh_privkey_base64_passphrase(void **state) NULL, &key); assert_true(rc == -1); + + /* This free is unnecessary, but the static analyser does not know */ + SSH_KEY_FREE(key); }