tests: Fix trivial memory leaks.
-- Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
15fc5c34c8
commit
62d10c2a38
@ -101,7 +101,7 @@ main (int argc, char *argv[])
|
||||
gpgme_data_t in, out;
|
||||
gpgme_decrypt_result_t decrypt_result;
|
||||
gpgme_verify_result_t verify_result;
|
||||
const char *cipher_2_asc = make_filename ("cipher-2.asc");
|
||||
char *cipher_2_asc = make_filename ("cipher-2.asc");
|
||||
char *agent_info;
|
||||
|
||||
init_gpgme (GPGME_PROTOCOL_OpenPGP);
|
||||
@ -114,6 +114,7 @@ main (int argc, char *argv[])
|
||||
gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL);
|
||||
|
||||
err = gpgme_data_new_from_file (&in, cipher_2_asc, 1);
|
||||
free (cipher_2_asc);
|
||||
fail_if_err (err);
|
||||
err = gpgme_data_new (&out);
|
||||
fail_if_err (err);
|
||||
|
@ -43,7 +43,7 @@ main (int argc, char *argv[])
|
||||
gpgme_error_t err;
|
||||
gpgme_data_t in, out;
|
||||
gpgme_decrypt_result_t result;
|
||||
const char *cipher_1_asc = make_filename ("cipher-1.asc");
|
||||
char *cipher_1_asc = make_filename ("cipher-1.asc");
|
||||
char *agent_info;
|
||||
|
||||
init_gpgme (GPGME_PROTOCOL_OpenPGP);
|
||||
@ -56,6 +56,7 @@ main (int argc, char *argv[])
|
||||
gpgme_set_passphrase_cb (ctx, passphrase_cb, NULL);
|
||||
|
||||
err = gpgme_data_new_from_file (&in, cipher_1_asc, 1);
|
||||
free (cipher_1_asc);
|
||||
fail_if_err (err);
|
||||
|
||||
err = gpgme_data_new (&out);
|
||||
|
@ -92,6 +92,7 @@ main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
gpgme_data_release (cipher);
|
||||
free (text2);
|
||||
gpgme_release (ctx);
|
||||
|
||||
return 0;
|
||||
|
@ -214,8 +214,8 @@ main (int argc, char *argv[])
|
||||
gpgme_error_t err;
|
||||
gpgme_data_t in;
|
||||
gpgme_import_result_t result;
|
||||
const char *pubkey_1_asc = make_filename ("pubkey-1.asc");
|
||||
const char *seckey_1_asc = make_filename ("seckey-1.asc");
|
||||
char *pubkey_1_asc = make_filename ("pubkey-1.asc");
|
||||
char *seckey_1_asc = make_filename ("seckey-1.asc");
|
||||
|
||||
init_gpgme (GPGME_PROTOCOL_OpenPGP);
|
||||
|
||||
@ -223,6 +223,7 @@ main (int argc, char *argv[])
|
||||
fail_if_err (err);
|
||||
|
||||
err = gpgme_data_new_from_file (&in, pubkey_1_asc, 1);
|
||||
free (pubkey_1_asc);
|
||||
fail_if_err (err);
|
||||
|
||||
err = gpgme_op_import (ctx, in);
|
||||
@ -232,6 +233,7 @@ main (int argc, char *argv[])
|
||||
gpgme_data_release (in);
|
||||
|
||||
err = gpgme_data_new_from_file (&in, seckey_1_asc, 1);
|
||||
free (seckey_1_asc);
|
||||
fail_if_err (err);
|
||||
|
||||
err = gpgme_op_import (ctx, in);
|
||||
|
@ -94,7 +94,7 @@ void *
|
||||
thread_two (void *name)
|
||||
{
|
||||
int i;
|
||||
const char *cipher_1_asc = make_filename ("cipher-1.asc");
|
||||
char *cipher_1_asc = make_filename ("cipher-1.asc");
|
||||
char *agent_info;
|
||||
|
||||
agent_info = getenv("GPG_AGENT_INFO");
|
||||
@ -135,6 +135,7 @@ thread_two (void *name)
|
||||
gpgme_data_release (out);
|
||||
gpgme_release (ctx);
|
||||
}
|
||||
free (cipher_1_asc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -142,8 +142,8 @@ main (int argc, char **argv)
|
||||
gpgme_error_t err;
|
||||
gpgme_data_t in;
|
||||
gpgme_import_result_t result;
|
||||
const char *cert_1 = make_filename ("cert_dfn_pca01.der");
|
||||
const char *cert_2 = make_filename ("cert_dfn_pca15.der");
|
||||
char *cert_1 = make_filename ("cert_dfn_pca01.der");
|
||||
char *cert_2 = make_filename ("cert_dfn_pca15.der");
|
||||
|
||||
init_gpgme (GPGME_PROTOCOL_CMS);
|
||||
|
||||
@ -153,6 +153,7 @@ main (int argc, char **argv)
|
||||
gpgme_set_protocol (ctx, GPGME_PROTOCOL_CMS);
|
||||
|
||||
err = gpgme_data_new_from_file (&in, cert_1, 1);
|
||||
free (cert_1);
|
||||
fail_if_err (err);
|
||||
|
||||
err = gpgme_op_import (ctx, in);
|
||||
@ -162,6 +163,7 @@ main (int argc, char **argv)
|
||||
gpgme_data_release (in);
|
||||
|
||||
err = gpgme_data_new_from_file (&in, cert_2, 1);
|
||||
free (cert_2);
|
||||
fail_if_err (err);
|
||||
|
||||
err = gpgme_op_import (ctx, in);
|
||||
|
@ -110,6 +110,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
fprintf (stderr, "Warning: Skipping unknown key %s\n",
|
||||
key->subkeys->fpr);
|
||||
gpgme_key_unref (key);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
|
@ -194,8 +194,8 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
round_t round = TEST_INITIALIZER;
|
||||
const char *text_filename = make_filename ("t-data-1.txt");
|
||||
const char *longer_text_filename = make_filename ("t-data-2.txt");
|
||||
char *text_filename = make_filename ("t-data-1.txt");
|
||||
char *longer_text_filename = make_filename ("t-data-2.txt");
|
||||
const char *missing_filename = "this-file-surely-does-not-exist";
|
||||
gpgme_error_t err = 0;
|
||||
gpgme_data_t data;
|
||||
@ -269,7 +269,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
case TEST_END:
|
||||
return 0;
|
||||
goto out;
|
||||
case TEST_INITIALIZER:
|
||||
/* Shouldn't happen. */
|
||||
fprintf (stderr, "%s:%d: impossible condition\n", __FILE__, __LINE__);
|
||||
@ -281,5 +281,8 @@ main (int argc, char **argv)
|
||||
write_test (round, data);
|
||||
gpgme_data_release (data);
|
||||
}
|
||||
out:
|
||||
free (text_filename);
|
||||
free (longer_text_filename);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user