From: Roy Marples Date: Fri, 6 May 2016 12:51:01 +0000 (+0000) Subject: Check a calloc failure. X-Git-Tag: v6.11.0~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=00f2cab5caa28a9dcef1816a25f66a165331f91a;p=thirdparty%2Fdhcpcd.git Check a calloc failure. --- diff --git a/dev.c b/dev.c index cbf97626..01f3ef6f 100644 --- 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) {