summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2018-10-26 12:14:04 -0600
committerAaron Ball <nullspoon@oper.io>2018-10-26 12:14:04 -0600
commitcea40d697824da4b3941f0d1814de14d364bb791 (patch)
tree972ca88ce0e06f2c05716e4bc71a2b9c996fe59f
parente1db7506e39532c6c3ef33e7bd2a3dc490b7f807 (diff)
downloadgpgedit-cea40d697824da4b3941f0d1814de14d364bb791.tar.gz
gpgedit-cea40d697824da4b3941f0d1814de14d364bb791.tar.xz
Moved key_release call to main.c
We should never free arguments passed to a function unless the function is a destructor, which gpg_encrypt is not. The keyids array originates in main, so this moves the release call to main.
-rw-r--r--src/gpg.c4
-rw-r--r--src/main.c1
2 files changed, 3 insertions, 2 deletions
diff --git a/src/gpg.c b/src/gpg.c
index 6509f45..335d03f 100644
--- a/src/gpg.c
+++ b/src/gpg.c
@@ -145,9 +145,9 @@ gpgme_key_t* gpg_keyids_to_key_t(gpgme_ctx_t ctx, char** keyids) {
return out;
}
-
void gpg_keyids_release(char** keyids) {
int i = 0;
+
while(keyids[i] != NULL) {
free(keyids[i]);
i++;
@@ -156,6 +156,7 @@ void gpg_keyids_release(char** keyids) {
}
+
void gpg_dump_key(gpgme_key_t key) {
printf("Recipient: %s\n", key->fpr);
printf(" protocol: %d\n", key->protocol);
@@ -236,7 +237,6 @@ size_t gpg_encrypt_file(char* infile, char* outfile, char** keyids) {
fclose(refd);
// cleanup
- gpg_keyids_release(keyids);
gpgme_data_release(indata);
gpgme_data_release(outdata);
gpgme_release(ctx);
diff --git a/src/main.c b/src/main.c
index 162982a..f5ae1c7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -60,6 +60,7 @@ int main(int argc, char* argv[]) {
gpg_encrypt_file(tmpfile, argv[1], keyids);
// Clean up tmpfile
+ gpg_keyids_release(keyids);
unlink(tmpfile);
return 0;
}

Generated by cgit