avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcrea...@apache.org
Subject svn commit: r1347734 - in /avro/trunk: CHANGES.txt lang/c/src/datum.c
Date Thu, 07 Jun 2012 17:40:32 GMT
Author: dcreager
Date: Thu Jun  7 17:40:30 2012
New Revision: 1347734

URL: http://svn.apache.org/viewvc?rev=1347734&view=rev
Log:
AVRO-1102. C: Fix memory leak in avro_string

We create a copy of the string, but weren't freeing that copy if the datum
instance couldn't be created.  Now we do.

Contributed by Maxim Pugachev.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/c/src/datum.c

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1347734&r1=1347733&r2=1347734&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Thu Jun  7 17:40:30 2012
@@ -126,6 +126,9 @@ Avro 1.7.0 (28 May 2012)
     AVRO-1087. C: avro_file_writer_open() and appending Avro values
     works correctly.  (Pugachev Maxim via dcreager)
 
+    AVRO-1102. C: Remove memory leak in avro_string().  (Maxim Pugachev via
+    dcreager)
+
 Avro 1.6.3 (5 March 2012)
 
     AVRO-1077. Missing 'inline' for union set function. (thiru)

Modified: avro/trunk/lang/c/src/datum.c
URL: http://svn.apache.org/viewvc/avro/trunk/lang/c/src/datum.c?rev=1347734&r1=1347733&r2=1347734&view=diff
==============================================================================
--- avro/trunk/lang/c/src/datum.c (original)
+++ avro/trunk/lang/c/src/datum.c Thu Jun  7 17:40:30 2012
@@ -70,7 +70,12 @@ avro_datum_t avro_string(const char *str
 		avro_set_error("Cannot copy string content");
 		return NULL;
 	}
-	return avro_string_private(p, 0, avro_str_free_wrapper);
+	avro_datum_t s_datum = avro_string_private(p, 0, avro_str_free_wrapper);
+	if (!s_datum) {
+		avro_str_free(p);
+	}
+
+	return s_datum;
 }
 
 avro_datum_t avro_givestring(const char *str,



Mime
View raw message