svn commit: samba r13975 - in branches/SAMBA_3_0/source: include lib

jra at samba.org jra at samba.org
Tue Mar 7 18:52:50 GMT 2006


Author: jra
Date: 2006-03-07 18:52:48 +0000 (Tue, 07 Mar 2006)
New Revision: 13975

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

Log:
Re-fix Coverity #156 - I had left the hidden arg. inconsistent
between Realloc and realloc_array.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/include/smb_macros.h
   branches/SAMBA_3_0/source/lib/util.c
   branches/SAMBA_3_0/source/lib/util_str.c


Changeset:
Modified: branches/SAMBA_3_0/source/include/smb_macros.h
===================================================================
--- branches/SAMBA_3_0/source/include/smb_macros.h	2006-03-07 18:52:45 UTC (rev 13974)
+++ branches/SAMBA_3_0/source/include/smb_macros.h	2006-03-07 18:52:48 UTC (rev 13975)
@@ -274,7 +274,7 @@
 #define SMB_REALLOC(p,s) Realloc((p),(s),True)	/* Always frees p on error or s == 0 */
 #define SMB_REALLOC_KEEP_OLD_ON_ERROR(p,s) Realloc((p),(s),False) /* Never frees p on error or s == 0 */
 #define SMB_REALLOC_ARRAY(p,type,count) (type *)realloc_array((p),sizeof(type),(count),True) /* Always frees p on error or s == 0 */
-#define SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(p,type,count) (type *)realloc_array((p),sizeof(type),(count),False) /* Always frees p on error or s == 0 */
+#define SMB_REALLOC_ARRAY_KEEP_OLD_ON_ERROR(p,type,count) (type *)realloc_array((p),sizeof(type),(count),False) /* Never frees p on error or s == 0 */
 #define SMB_CALLOC_ARRAY(type,count) (type *)calloc_array(sizeof(type),(count))
 #define SMB_XMALLOC_P(type) (type *)smb_xmalloc_array(sizeof(type),1)
 #define SMB_XMALLOC_ARRAY(type,count) (type *)smb_xmalloc_array(sizeof(type),(count))

Modified: branches/SAMBA_3_0/source/lib/util.c
===================================================================
--- branches/SAMBA_3_0/source/lib/util.c	2006-03-07 18:52:45 UTC (rev 13974)
+++ branches/SAMBA_3_0/source/lib/util.c	2006-03-07 18:52:48 UTC (rev 13975)
@@ -1009,15 +1009,15 @@
  Type-safe realloc.
 ****************************************************************************/
 
-void *realloc_array(void *p, size_t el_size, unsigned int count, BOOL keep_old_on_error)
+void *realloc_array(void *p, size_t el_size, unsigned int count, BOOL free_old_on_error)
 {
 	if (count >= MAX_ALLOC_SIZE/el_size) {
-		if (!keep_old_on_error) {
+		if (free_old_on_error) {
 			SAFE_FREE(p);
 		}
 		return NULL;
 	}
-	return Realloc(p, el_size*count, keep_old_on_error);
+	return Realloc(p, el_size*count, free_old_on_error);
 }
 
 /****************************************************************************

Modified: branches/SAMBA_3_0/source/lib/util_str.c
===================================================================
--- branches/SAMBA_3_0/source/lib/util_str.c	2006-03-07 18:52:45 UTC (rev 13974)
+++ branches/SAMBA_3_0/source/lib/util_str.c	2006-03-07 18:52:48 UTC (rev 13975)
@@ -1779,8 +1779,9 @@
 				DEBUG(0,("str_list_copy: Unable to re-allocate memory"));
 				str_list_free(&list);
 				return False;
-			} else
+			} else {
 				list = rlist;
+			}
 			memset (&list[num], 0, ((sizeof(char **)) * (S_LIST_ABS +1)));
 		}
 		



More information about the samba-cvs mailing list