]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Check a calloc failure.
authorRoy Marples <roy@marples.name>
Fri, 6 May 2016 12:51:01 +0000 (12:51 +0000)
committerRoy Marples <roy@marples.name>
Fri, 6 May 2016 12:51:01 +0000 (12:51 +0000)
dev.c

diff --git a/dev.c b/dev.c
index cbf976267d9fa16ba579d46a8364750359193e20..01f3ef6f60590419e29e3d6e2aec1dcc8e3a0ad5 100644 (file)
--- a/dev.c
+++ b/dev.c
@@ -103,7 +103,11 @@ dev_start2(struct dhcpcd_ctx *ctx, const char *name)
                dlclose(h);
                return -1;
        }
-       ctx->dev = calloc(1, sizeof(*ctx->dev));
+       if ((ctx->dev = calloc(1, sizeof(*ctx->dev))) == NULL) {
+               logger(ctx, LOG_ERR, "%s: calloc: %m", __func__);
+               dlclose(h);
+               return -1;
+       }
        dev_dhcpcd.handle_interface = &dhcpcd_handleinterface;
        fptr(ctx->dev, &dev_dhcpcd);
        if (ctx->dev->start  == NULL || (r = ctx->dev->start()) == -1) {