Exit if allocation fails

Signed-off-by: Michael Santos <michael.santos@gmail.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
Michael Santos 2011-03-16 10:04:13 -04:00 committed by Daniel Lezcano
parent 071a2b8cc9
commit 302aaa2b2d

View File

@ -69,6 +69,10 @@ int main(int argc, char *argv[])
return -1;
regexp = malloc(strlen(my_args.name) + 3);
if (!regexp) {
ERROR("failed to allocate memory");
return -1;
}
sprintf(regexp, "^%s$", my_args.name);
if (regcomp(&preg, regexp, REG_NOSUB|REG_EXTENDED)) {