From e1a671f666b695c5f1bfd34bbce01832104571f0 Mon Sep 17 00:00:00 2001 From: wiz Date: Wed, 5 Jan 2011 15:40:55 +0000 Subject: Fix realloc error. Found by cppcheck. --- hunt/hunt/hunt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'hunt') diff --git a/hunt/hunt/hunt.c b/hunt/hunt/hunt.c index 6db20116..2d1747b4 100644 --- a/hunt/hunt/hunt.c +++ b/hunt/hunt/hunt.c @@ -1,4 +1,4 @@ -/* $NetBSD: hunt.c,v 1.36 2009/08/12 07:42:11 dholland Exp $ */ +/* $NetBSD: hunt.c,v 1.37 2011/01/05 15:40:55 wiz Exp $ */ /* * Copyright (c) 1983-2003, Regents of the University of California. * All rights reserved. @@ -32,7 +32,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hunt.c,v 1.36 2009/08/12 07:42:11 dholland Exp $"); +__RCSID("$NetBSD: hunt.c,v 1.37 2011/01/05 15:40:55 wiz Exp $"); #endif /* not lint */ #include @@ -468,8 +468,12 @@ get_response: set[0].events = POLLIN; for (;;) { if (listc + 1 >= listmax) { + void *newlistv; listmax += 20; - listv = realloc(listv, listmax * sizeof(SOCKET)); + newlistv = realloc(listv, listmax * sizeof(SOCKET)); + if (newlistv == NULL) + leave(1, "realloc"); + listv = (SOCKET *)newlistv; } if (poll(set, 1, 1000) == 1 && -- cgit v1.2.3-56-ge451