svn commit: samba r14769 - in trunk/source/registry: .

jra at samba.org jra at samba.org
Wed Mar 29 22:51:32 GMT 2006


Author: jra
Date: 2006-03-29 22:51:31 +0000 (Wed, 29 Mar 2006)
New Revision: 14769

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

Log:
Fix potential null deref coverity bugs #255, #256.
Jeremy.

Modified:
   trunk/source/registry/reg_objects.c


Changeset:
Modified: trunk/source/registry/reg_objects.c
===================================================================
--- trunk/source/registry/reg_objects.c	2006-03-29 22:51:23 UTC (rev 14768)
+++ trunk/source/registry/reg_objects.c	2006-03-29 22:51:31 UTC (rev 14769)
@@ -270,8 +270,6 @@
 int regval_ctr_addvalue( REGVAL_CTR *ctr, const char *name, uint16 type, 
                          const char *data_p, size_t size )
 {
-	REGISTRY_VALUE **ppreg;
-	
 	if ( !name )
 		return ctr->num_values;
 
@@ -281,17 +279,24 @@
 
 	/* allocate a slot in the array of pointers */
 		
-	if (  ctr->num_values == 0 )
+	if (  ctr->num_values == 0 ) {
 		ctr->values = TALLOC_P( ctr, REGISTRY_VALUE *);
-	else {
-		ppreg = TALLOC_REALLOC_ARRAY( ctr, ctr->values, REGISTRY_VALUE *, ctr->num_values+1 );
-		if ( ppreg )
-			ctr->values = ppreg;
+	} else {
+		ctr->values = TALLOC_REALLOC_ARRAY( ctr, ctr->values, REGISTRY_VALUE *, ctr->num_values+1 );
 	}
 
+	if (!ctr->values) {
+		ctr->num_values = 0;
+		return 0;
+	}
+
 	/* allocate a new value and store the pointer in the arrya */
 		
 	ctr->values[ctr->num_values] = TALLOC_P( ctr, REGISTRY_VALUE);
+	if (!ctr->values[ctr->num_values]) {
+		ctr->num_values = 0;
+		return 0;
+	}
 
 	/* init the value */
 	
@@ -310,23 +315,27 @@
 
 int regval_ctr_copyvalue( REGVAL_CTR *ctr, REGISTRY_VALUE *val )
 {
-	REGISTRY_VALUE **ppreg;
-	
-	if ( val )
-	{
+	if ( val ) {
 		/* allocate a slot in the array of pointers */
 		
-		if (  ctr->num_values == 0 )
+		if (  ctr->num_values == 0 ) {
 			ctr->values = TALLOC_P( ctr, REGISTRY_VALUE *);
-		else {
-			ppreg = TALLOC_REALLOC_ARRAY( ctr, ctr->values, REGISTRY_VALUE *, ctr->num_values+1 );
-			if ( ppreg )
-				ctr->values = ppreg;
+		} else {
+			ctr->values = TALLOC_REALLOC_ARRAY( ctr, ctr->values, REGISTRY_VALUE *, ctr->num_values+1 );
 		}
 
+		if (!ctr->values) {
+			ctr->num_values = 0;
+			return 0;
+		}
+
 		/* allocate a new value and store the pointer in the arrya */
 		
 		ctr->values[ctr->num_values] = TALLOC_P( ctr, REGISTRY_VALUE);
+		if (!ctr->values[ctr->num_values]) {
+			ctr->num_values = 0;
+			return 0;
+		}
 
 		/* init the value */
 	
@@ -411,4 +420,3 @@
 	
 	return data;
 }
-



More information about the samba-cvs mailing list