svn commit: samba r6238 - in branches/SAMBA_4_0/source/lib/tdb/common: .

jra at samba.org jra at samba.org
Thu Apr 7 19:50:55 GMT 2005


Author: jra
Date: 2005-04-07 19:50:54 +0000 (Thu, 07 Apr 2005)
New Revision: 6238

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=6238

Log:
Ensure if realloc fails on an internal
tdb we fail gracefully.
Jeremy.


Modified:
   branches/SAMBA_4_0/source/lib/tdb/common/tdb.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/tdb/common/tdb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/tdb/common/tdb.c	2005-04-07 19:43:19 UTC (rev 6237)
+++ branches/SAMBA_4_0/source/lib/tdb/common/tdb.c	2005-04-07 19:50:54 UTC (rev 6238)
@@ -802,9 +802,14 @@
 
 	tdb->map_size += size;
 
-	if (tdb->flags & TDB_INTERNAL)
-		tdb->map_ptr = realloc(tdb->map_ptr, tdb->map_size);
-	else {
+	if (tdb->flags & TDB_INTERNAL) {
+		char *new_map_ptr = realloc(tdb->map_ptr, tdb->map_size);
+		if (!new_map_ptr) {
+			tdb->map_size -= size;
+			goto fail;
+		}
+		tdb->map_ptr = new_map_ptr;
+	} else {
 		/*
 		 * We must ensure the file is remapped before adding the space
 		 * to ensure consistency with systems like OpenBSD where



More information about the samba-cvs mailing list