summaryrefslogtreecommitdiffstats
path: root/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2014-07-03 10:07:35 +0000
committerRoy Marples <roy@marples.name>2014-07-03 10:07:35 +0000
commita0bbca2d3ce38bcf0c4bbe0c3c59acea21780edf (patch)
treedcf7a0f4b0ba6e85600d09880787fe8a149007fd /dhcpcd.c
parent39e51da4e7b941566e0df4cbbe50d8bacba87e4d (diff)
downloaddhcpcd-a0bbca2d3ce38bcf0c4bbe0c3c59acea21780edf.tar.xz
Fix a potential segfault when reloading configurations.
Thanks to Eelco Dolstra for the patch.
Diffstat (limited to 'dhcpcd.c')
-rw-r--r--dhcpcd.c8
1 files changed, 4 insertions, 4 deletions
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;
}