From: Roy Marples Date: Thu, 3 Jul 2014 10:07:35 +0000 (+0000) Subject: Fix a potential segfault when reloading configurations. X-Git-Tag: v6.4.1~29 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a0bbca2d3ce38bcf0c4bbe0c3c59acea21780edf;p=thirdparty%2Fdhcpcd.git Fix a potential segfault when reloading configurations. Thanks to Eelco Dolstra for the patch. --- diff --git a/dhcpcd.c b/dhcpcd.c index 3322a271..294364cf 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -139,14 +139,14 @@ free_globals(struct dhcpcd_ctx *ctx) struct dhcp_opt *opt; if (ctx->ifac) { - for (ctx->ifac--; ctx->ifac >= 0; ctx->ifac--) - free(ctx->ifav[ctx->ifac]); + for (; ctx->ifac > 0; ctx->ifac--) + free(ctx->ifav[ctx->ifac - 1]); free(ctx->ifav); ctx->ifav = NULL; } if (ctx->ifdc) { - for (ctx->ifdc--; ctx->ifdc >= 0; ctx->ifdc--) - free(ctx->ifdv[ctx->ifdc]); + for (; ctx->ifdc > 0; ctx->ifdc--) + free(ctx->ifdv[ctx->ifdc - 1]); free(ctx->ifdv); ctx->ifdv = NULL; }