[PATCH] avoid use of freed pointer

Jim Meyering jim at meyering.net
Tue Sep 20 16:26:37 CEST 2011


Without this patch, pk2 would be freed twice.

>From 2a18a4b757e0896e738fefbbaa8ff8c23a9edf89 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Tue, 20 Sep 2011 16:20:39 +0200
Subject: [PATCH] avoid use of freed pointer

If we free pk2 at the top of the for-loop, set it to NULL
so that we don't free it again just before returning.
* revoke.c (gen_desig_revoke): Don't use pk2 after freeing it.
---
 g10/ChangeLog |    7 +++++++
 g10/revoke.c  |    5 ++++-
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/g10/ChangeLog b/g10/ChangeLog
index be2ad0b..8ae5747 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,10 @@
+2011-09-20  Jim Meyering  <meyering at redhat.com>
+
+	avoid use of freed pointer
+	If we free pk2 at the top of the for-loop, set it to NULL
+	so that we don't free it again just before returning.
+	* revoke.c (gen_desig_revoke): Don't use pk2 after freeing it.
+
 2011-09-20  Werner Koch  <wk at g10code.com>

 	* sign.c (sign_file, clearsign_file, sign_symencrypt_file):
diff --git a/g10/revoke.c b/g10/revoke.c
index c18dfb9..2c696cc 100644
--- a/g10/revoke.c
+++ b/g10/revoke.c
@@ -263,7 +263,10 @@ gen_desig_revoke( const char *uname, strlist_t locusr )
 	SK_LIST list;

 	if (pk2)
-	  free_public_key (pk2);
+	  {
+	    free_public_key (pk2);
+	    pk2 = NULL;
+	  }

 	if(sk_list)
 	  {
--
1.7.7.rc0.362.g5a14



More information about the Gnupg-devel mailing list