/* 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*));
unsigned hash ;
int i ;
+ if (key == NULL) {
+ return;
+ }
+
hash = dictionary_hash(key);
for (i=0 ; i<d->size ; i++) {
if (d->key[i]==NULL)
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 ;
/*
* 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++ ;