Check strdup() return values

Reviewed by:	kris
This commit is contained in:
Chris D. Faulhaber 2001-01-20 01:22:31 +00:00
parent 89689ecb7c
commit aecdf0ebbf
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=71277
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.name = oldone->evcmd.name;
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;
}
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)
goto parse_err;
*manuf = strdup(_manuf);
*version = strdup(_version);
*device = strdup(_device);
if ((*manuf = strdup(_manuf)) == NULL) {
warn("strdup");
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) {
warn("strdup");
goto err;