Check strdup() return values

Reviewed by:	kris
This commit is contained in:
jedgar 2001-01-20 01:22:31 +00:00
parent 2ceeaae1ed
commit ff858da87b
2 changed files with 14 additions and 4 deletions

View File

@ -139,7 +139,8 @@ event_cmd_exec_clone(void *this)
newone->evcmd.len = oldone->evcmd.len; newone->evcmd.len = oldone->evcmd.len;
newone->evcmd.name = oldone->evcmd.name; newone->evcmd.name = oldone->evcmd.name;
newone->evcmd.op = oldone->evcmd.op; newone->evcmd.op = oldone->evcmd.op;
newone->line = strdup(oldone->line); if ((newone->line = strdup(oldone->line)) == NULL)
err(1, "out of memory");
return (struct event_cmd *) newone; return (struct event_cmd *) newone;
} }
void void

View File

@ -194,9 +194,18 @@ get_slot_info(int so, int slot, char **manuf, char **version, char
if (s != NULL && strchr(s, '~') != NULL) if (s != NULL && strchr(s, '~') != NULL)
goto parse_err; goto parse_err;
*manuf = strdup(_manuf); if ((*manuf = strdup(_manuf)) == NULL) {
*version = strdup(_version); warn("strdup");
*device = strdup(_device); goto err;
}
if ((*version = strdup(_version)) == NULL) {
warn("strdup");
goto err;
}
if ((*device = strdup(_device)) == NULL) {
warn("strdup");
goto err;
}
if (*manuf == NULL || *version == NULL || *device == NULL) { if (*manuf == NULL || *version == NULL || *device == NULL) {
warn("strdup"); warn("strdup");
goto err; goto err;