summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael J Gruber <git@drmicha.warpmail.net>2014-06-23 07:05:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-06-23 22:50:29 (GMT)
commit01e57b5d91b0c9f2ac93708c5c2cbcd4731ddd34 (patch)
tree6cac8943a32b4a22c3c4e78d41a538f77b78a590
parent0953113bb5687f42bcdfc3d20dd3a125784ad383 (diff)
downloadgit-01e57b5d91b0c9f2ac93708c5c2cbcd4731ddd34.zip
git-01e57b5d91b0c9f2ac93708c5c2cbcd4731ddd34.tar.gz
git-01e57b5d91b0c9f2ac93708c5c2cbcd4731ddd34.tar.bz2
gpg-interface: provide clear helper for struct signature_check
The struct has been growing members whose malloced memory needs to be freed. Do this with one helper function so that no malloced memory shall be left unfreed. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/merge.c5
-rw-r--r--gpg-interface.c12
-rw-r--r--gpg-interface.h1
-rw-r--r--pretty.c3
4 files changed, 15 insertions, 6 deletions
diff --git a/builtin/merge.c b/builtin/merge.c
index 428ca24..e50323d 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1282,10 +1282,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
printf(_("Commit %s has a good GPG signature by %s\n"),
hex, signature_check.signer);
- free(signature_check.gpg_output);
- free(signature_check.gpg_status);
- free(signature_check.signer);
- free(signature_check.key);
+ signature_check_clear(&signature_check);
}
}
diff --git a/gpg-interface.c b/gpg-interface.c
index 8b0e874..e71b59d 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -7,6 +7,18 @@
static char *configured_signing_key;
static const char *gpg_program = "gpg";
+void signature_check_clear(struct signature_check *sigc)
+{
+ free(sigc->gpg_output);
+ free(sigc->gpg_status);
+ free(sigc->signer);
+ free(sigc->key);
+ sigc->gpg_output = NULL;
+ sigc->gpg_status = NULL;
+ sigc->signer = NULL;
+ sigc->key = NULL;
+}
+
void set_signing_key(const char *key)
{
free(configured_signing_key);
diff --git a/gpg-interface.h b/gpg-interface.h
index a85cb5b..9f0784a 100644
--- a/gpg-interface.h
+++ b/gpg-interface.h
@@ -13,6 +13,7 @@ struct signature_check {
char *key;
};
+extern void signature_check_clear(struct signature_check *sigc);
extern int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *signing_key);
extern int verify_signed_buffer(const char *payload, size_t payload_size, const char *signature, size_t signature_size, struct strbuf *gpg_output, struct strbuf *gpg_status);
extern int git_gpg_config(const char *, const char *, void *);
diff --git a/pretty.c b/pretty.c
index e1e2cad..f6a0023 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1532,8 +1532,7 @@ void format_commit_message(const struct commit *commit,
free(context.commit_encoding);
logmsg_free(context.message, commit);
- free(context.signature_check.gpg_output);
- free(context.signature_check.signer);
+ signature_check_clear(&context.signature_check);
}
static void pp_header(struct pretty_print_context *pp,