summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-11-28 09:06:04 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:16:10 -0500
commit985248b638f4336688cd47f4776d4f8e26fc74c6 (patch)
tree831544d5d0a44411e5f0a8334f7b24c76b916de6 /source3
parent78a0932145780d835d2ae7b7057328fc2c799a2a (diff)
downloadsamba-985248b638f4336688cd47f4776d4f8e26fc74c6.tar.gz
samba-985248b638f4336688cd47f4776d4f8e26fc74c6.tar.bz2
samba-985248b638f4336688cd47f4776d4f8e26fc74c6.zip
r19928: Fix klokwork id 4509, 4573, 4574.
(This used to be commit c004d041817f0bdf99a205090c8b026dfb0d81bc)
Diffstat (limited to 'source3')
-rw-r--r--source3/iniparser/src/dictionary.c8
-rw-r--r--source3/iniparser/src/iniparser.c9
2 files changed, 14 insertions, 3 deletions
diff --git a/source3/iniparser/src/dictionary.c b/source3/iniparser/src/dictionary.c
index 1f55cb4c24..edbd6f9a35 100644
--- a/source3/iniparser/src/dictionary.c
+++ b/source3/iniparser/src/dictionary.c
@@ -114,7 +114,9 @@ dictionary * dictionary_new(int size)
/* 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 @@ void dictionary_unset(dictionary * d, char * key)
unsigned hash ;
int i ;
+ if (key == NULL) {
+ return;
+ }
+
hash = dictionary_hash(key);
for (i=0 ; i<d->size ; i++) {
if (d->key[i]==NULL)
diff --git a/source3/iniparser/src/iniparser.c b/source3/iniparser/src/iniparser.c
index 67f42a347d..0cb452b265 100644
--- a/source3/iniparser/src/iniparser.c
+++ b/source3/iniparser/src/iniparser.c
@@ -259,7 +259,9 @@ char * iniparser_getstring(dictionary * d, const char * key, char * def)
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 @@ dictionary * iniparser_load(const char * ininame)
/*
* 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++ ;