diff options
Diffstat (limited to 'include.c')
-rw-r--r-- | include.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -54,7 +54,10 @@ issymbolic(const char *dir, const char *component) if (strcmp(*pp, buf) == 0) return (TRUE); if (lstat(buf, &st) == 0 && (st.st_mode & S_IFMT) == S_IFLNK) { - *pp++ = strdup(buf); + char *p = strdup(buf); + if (p == NULL) + fatalerr("strdup() failure in %s()\n", __func__); + *pp++ = p; if (pp >= ¬dotdot[MAXDIRS]) fatalerr("out of .. dirs, increase MAXDIRS\n"); return (TRUE); @@ -151,11 +154,16 @@ newinclude(const char *newfile, const char *incstring) if (inclistp == inclist + MAXFILES - 1) fatalerr("out of space: increase MAXFILES\n"); ip->i_file = strdup(newfile); + if (ip->i_file == NULL) + fatalerr("strdup() failure in %s()\n", __func__); if (incstring == NULL) ip->i_incstring = ip->i_file; - else + else { ip->i_incstring = strdup(incstring); + if (ip->i_incstring == NULL) + fatalerr("strdup() failure in %s()\n", __func__); + } inclistnext = inclistp; return (ip); @@ -205,6 +213,9 @@ included_by(struct inclist *ip, struct inclist *newfile) ip->i_merged = reallocarray(ip->i_merged, ip->i_listlen, sizeof(boolean)); } + if ((ip->i_list == NULL) || (ip->i_merged == NULL)) + fatalerr("malloc()/realloc() failure in %s()\n", __func__); + ip->i_list[ip->i_listlen - 1] = newfile; ip->i_merged[ip->i_listlen - 1] = FALSE; } |