[svn] gpgme - r1182 - in trunk: . doc gpgme

svn author marcus cvs at cvs.gnupg.org
Mon Sep 25 16:57:01 CEST 2006


Author: marcus
Date: 2006-09-25 16:57:00 +0200 (Mon, 25 Sep 2006)
New Revision: 1182

Modified:
   trunk/NEWS
   trunk/doc/ChangeLog
   trunk/doc/gpgme.texi
   trunk/gpgme/ChangeLog
   trunk/gpgme/data-mem.c
Log:
doc/
2006-09-25  Marcus Brinkmann  <marcus at g10code.de>

        * gpgme.texi (Destroying Data Buffers): Clarify that
        gpgme_data_release_and_get_mem destroys DH unconditionally.

gpgme/
2006-09-25  Marcus Brinkmann  <marcus at g10code.de>

        * data-mem.c (gpgme_data_release_and_get_mem): Release the data
        object properly.



Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2006-09-22 12:29:36 UTC (rev 1181)
+++ trunk/NEWS	2006-09-25 14:57:00 UTC (rev 1182)
@@ -1,6 +1,8 @@
 Noteworthy changes in version 1.1.3 (unreleased)
 ------------------------------------------------
 
+ * Fixed a memory leak in gpgme_data_release_and_get_mem.
+
  * Interface changes relative to the 1.1.1 release:
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Modified: trunk/doc/ChangeLog
===================================================================
--- trunk/doc/ChangeLog	2006-09-22 12:29:36 UTC (rev 1181)
+++ trunk/doc/ChangeLog	2006-09-25 14:57:00 UTC (rev 1182)
@@ -1,3 +1,8 @@
+2006-09-25  Marcus Brinkmann  <marcus at g10code.de>
+
+	* gpgme.texi (Destroying Data Buffers): Clarify that
+	gpgme_data_release_and_get_mem destroys DH unconditionally.
+
 2005-03-24  Marcus Brinkmann  <marcus at g10code.de>
 
 	* gpgme.texi (Library Version Check): Make example code compatible

Modified: trunk/doc/gpgme.texi
===================================================================
--- trunk/doc/gpgme.texi	2006-09-22 12:29:36 UTC (rev 1181)
+++ trunk/doc/gpgme.texi	2006-09-25 14:57:00 UTC (rev 1182)
@@ -1719,7 +1719,8 @@
 made for this purpose.
 
 In case an error returns, or there is no suitable data buffer that can
-be returned to the user, the function will return @code{NULL}.
+be returned to the user, the function will return @code{NULL}.  In any
+case, the data object @var{dh} is destroyed.
 @end deftypefun
 
 

Modified: trunk/gpgme/ChangeLog
===================================================================
--- trunk/gpgme/ChangeLog	2006-09-22 12:29:36 UTC (rev 1181)
+++ trunk/gpgme/ChangeLog	2006-09-25 14:57:00 UTC (rev 1182)
@@ -1,3 +1,8 @@
+2006-09-25  Marcus Brinkmann  <marcus at g10code.de>
+
+	* data-mem.c (gpgme_data_release_and_get_mem): Release the data
+	object properly.
+
 2006-09-22  Marcus Brinkmann  <marcus at g10code.de>
 
 	* keylist.c (keylist_colon_handler): Move debug output after

Modified: trunk/gpgme/data-mem.c
===================================================================
--- trunk/gpgme/data-mem.c	2006-09-22 12:29:36 UTC (rev 1181)
+++ trunk/gpgme/data-mem.c	2006-09-25 14:57:00 UTC (rev 1182)
@@ -210,20 +210,32 @@
   char *str = NULL;
 
   if (!dh || dh->cbs != &mem_cbs)
-    return NULL;
+    {
+      gpgme_data_release (dh);
+      return NULL;
+    }
 
   str = dh->data.mem.buffer;
   if (!str && dh->data.mem.orig_buffer)
     {
       str = malloc (dh->data.mem.length);
       if (!str)
-	return NULL;
+	{
+	  gpgme_data_release (dh);
+	  return NULL;
+	}
       memcpy (str, dh->data.mem.orig_buffer, dh->data.mem.length);
     }
+  else
+    /* Prevent mem_release from releasing the buffer memory.  We must
+       not fail from this point.  */
+    dh->data.mem.buffer = NULL;
 
   if (r_len)
     *r_len = dh->data.mem.length;
 
+  gpgme_data_release (dh);
+
   return str;
 }
 




More information about the Gnupg-commits mailing list