svn commit: samba r19928 - in branches: SAMBA_3_0/source/iniparser/src SAMBA_3_0_24/source/iniparser/src

vlendec at samba.org vlendec at samba.org
Tue Nov 28 09:06:05 GMT 2006


Author: vlendec
Date: 2006-11-28 09:06:04 +0000 (Tue, 28 Nov 2006)
New Revision: 19928

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

Log:
Fix klokwork id 4509, 4573, 4574.
Modified:
   branches/SAMBA_3_0/source/iniparser/src/dictionary.c
   branches/SAMBA_3_0/source/iniparser/src/iniparser.c
   branches/SAMBA_3_0_24/source/iniparser/src/dictionary.c
   branches/SAMBA_3_0_24/source/iniparser/src/iniparser.c


Changeset:
Modified: branches/SAMBA_3_0/source/iniparser/src/dictionary.c
===================================================================
--- branches/SAMBA_3_0/source/iniparser/src/dictionary.c	2006-11-28 08:11:04 UTC (rev 19927)
+++ branches/SAMBA_3_0/source/iniparser/src/dictionary.c	2006-11-28 09:06:04 UTC (rev 19928)
@@ -114,7 +114,9 @@
 	/* If no size was specified, allocate space for DICTMINSZ */
 	if (size<DICTMINSZ) size=DICTMINSZ ;
 
-	d = (dictionary *)calloc(1, sizeof(dictionary));
+	if (!(d = (dictionary *)calloc(1, sizeof(dictionary)))) {
+		return NULL;
+	}
 	d->size = size ;
 	d->val  = (char **)calloc(size, sizeof(char*));
 	d->key  = (char **)calloc(size, sizeof(char*));
@@ -355,6 +357,10 @@
 	unsigned	hash ;
 	int			i ;
 
+	if (key == NULL) {
+		return;
+	}
+
 	hash = dictionary_hash(key);
 	for (i=0 ; i<d->size ; i++) {
         if (d->key[i]==NULL)

Modified: branches/SAMBA_3_0/source/iniparser/src/iniparser.c
===================================================================
--- branches/SAMBA_3_0/source/iniparser/src/iniparser.c	2006-11-28 08:11:04 UTC (rev 19927)
+++ branches/SAMBA_3_0/source/iniparser/src/iniparser.c	2006-11-28 09:06:04 UTC (rev 19928)
@@ -259,7 +259,9 @@
     if (d==NULL || key==NULL)
         return def ;
 
-    lc_key = strdup(strlwc(key));
+    if (!(lc_key = strdup(strlwc(key)))) {
+	    return NULL;
+    }
     sval = dictionary_get(d, lc_key, def);
     free(lc_key);
     return sval ;
@@ -462,7 +464,10 @@
     /*
      * Initialize a new dictionary entry
      */
-    d = dictionary_new(0);
+    if (!(d = dictionary_new(0))) {
+	    fclose(ini);
+	    return NULL;
+    }
     lineno = 0 ;
     while (fgets(lin, ASCIILINESZ, ini)!=NULL) {
         lineno++ ;

Modified: branches/SAMBA_3_0_24/source/iniparser/src/dictionary.c
===================================================================
--- branches/SAMBA_3_0_24/source/iniparser/src/dictionary.c	2006-11-28 08:11:04 UTC (rev 19927)
+++ branches/SAMBA_3_0_24/source/iniparser/src/dictionary.c	2006-11-28 09:06:04 UTC (rev 19928)
@@ -114,7 +114,9 @@
 	/* If no size was specified, allocate space for DICTMINSZ */
 	if (size<DICTMINSZ) size=DICTMINSZ ;
 
-	d = (dictionary *)calloc(1, sizeof(dictionary));
+	if (!(d = (dictionary *)calloc(1, sizeof(dictionary)))) {
+		return NULL;
+	}
 	d->size = size ;
 	d->val  = (char **)calloc(size, sizeof(char*));
 	d->key  = (char **)calloc(size, sizeof(char*));
@@ -355,6 +357,10 @@
 	unsigned	hash ;
 	int			i ;
 
+	if (key == NULL) {
+		return;
+	}
+
 	hash = dictionary_hash(key);
 	for (i=0 ; i<d->size ; i++) {
         if (d->key[i]==NULL)

Modified: branches/SAMBA_3_0_24/source/iniparser/src/iniparser.c
===================================================================
--- branches/SAMBA_3_0_24/source/iniparser/src/iniparser.c	2006-11-28 08:11:04 UTC (rev 19927)
+++ branches/SAMBA_3_0_24/source/iniparser/src/iniparser.c	2006-11-28 09:06:04 UTC (rev 19928)
@@ -259,7 +259,9 @@
     if (d==NULL || key==NULL)
         return def ;
 
-    lc_key = strdup(strlwc(key));
+    if (!(lc_key = strdup(strlwc(key)))) {
+	    return NULL;
+    }
     sval = dictionary_get(d, lc_key, def);
     free(lc_key);
     return sval ;
@@ -462,7 +464,10 @@
     /*
      * Initialize a new dictionary entry
      */
-    d = dictionary_new(0);
+    if (!(d = dictionary_new(0))) {
+	    fclose(ini);
+	    return NULL;
+    }
     lineno = 0 ;
     while (fgets(lin, ASCIILINESZ, ini)!=NULL) {
         lineno++ ;



More information about the samba-cvs mailing list