(hashtabnew): check for NULL before setting structure.

Coverity, NetBSD CID#4


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@17016 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2006-04-07 22:16:00 +00:00
parent 8f297fdb5c
commit a8a053df5c

View File

@@ -53,17 +53,16 @@ hashtabnew(int sz,
assert(sz > 0); assert(sz > 0);
htab = (Hashtab *) malloc(sizeof(Hashtab) + (sz - 1) * sizeof(Hashentry *)); htab = (Hashtab *) malloc(sizeof(Hashtab) + (sz - 1) * sizeof(Hashentry *));
if (htab == NULL)
return NULL;
for (i = 0; i < sz; ++i) for (i = 0; i < sz; ++i)
htab->tab[i] = NULL; htab->tab[i] = NULL;
if (htab == NULL) { htab->cmp = cmp;
return NULL; htab->hash = hash;
} else { htab->sz = sz;
htab->cmp = cmp; return htab;
htab->hash = hash;
htab->sz = sz;
return htab;
}
} }
/* Intern search function */ /* Intern search function */