diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2017-07-12 07:40:16 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2017-07-12 07:41:37 +0200 |
commit | d1dbb3ae67c156093419157eaf2fc6b8281432b8 (patch) | |
tree | 91ffb04bd8cf650c1092ee6cb2b62f24fab77b04 | |
parent | c4c95bf42985182fde34f3ccf09c53f4b3f00063 (diff) | |
download | libgit2-cmn/tag-bad-signature.tar.gz |
signature: don't leave a dangling pointer to the strings on parse failurecmn/tag-bad-signature
If the signature is invalid but we detect that after allocating the strings, we
free them. We however leave that pointer dangling in the structure the caller
gave us, which can lead to double-free.
Set these pointers to `NULL` after freeing their memory to avoid this.
-rw-r--r-- | src/signature.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/signature.c b/src/signature.c index a56b8a299..25e0ee723 100644 --- a/src/signature.c +++ b/src/signature.c @@ -231,6 +231,7 @@ int git_signature__parse(git_signature *sig, const char **buffer_out, if (git__strtol64(&sig->when.time, time_start, &time_end, 10) < 0) { git__free(sig->name); git__free(sig->email); + sig->name = sig->email = NULL; return signature_error("invalid Unix timestamp"); } |