avoid use of freed pointer
authorJim Meyering <jim@meyering.net>
Tue, 20 Sep 2011 14:26:37 +0000 (16:26 +0200)
committerWerner Koch <wk@gnupg.org>
Tue, 20 Sep 2011 16:12:07 +0000 (18:12 +0200)
Without this patch, pk2 would be freed twice.

>From 2a18a4b757e0896e738fefbbaa8ff8c23a9edf89 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@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
g10/revoke.c

index be2ad0b..8ae5747 100644 (file)
@@ -1,3 +1,10 @@
+2011-09-20  Jim Meyering  <meyering@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@g10code.com>
 
        * sign.c (sign_file, clearsign_file, sign_symencrypt_file):
index c18dfb9..2c696cc 100644 (file)
@@ -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)
          {