Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/hunt/hunt Fix realloc error. Found by cppcheck.



details:   https://anonhg.NetBSD.org/src/rev/874f20d7c44e
branches:  trunk
changeset: 760458:874f20d7c44e
user:      wiz <wiz%NetBSD.org@localhost>
date:      Wed Jan 05 15:40:55 2011 +0000

description:
Fix realloc error. Found by cppcheck.

diffstat:

 games/hunt/hunt/hunt.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (32 lines):

diff -r 92ed416bb3e1 -r 874f20d7c44e games/hunt/hunt/hunt.c
--- a/games/hunt/hunt/hunt.c    Wed Jan 05 15:39:19 2011 +0000
+++ b/games/hunt/hunt/hunt.c    Wed Jan 05 15:40:55 2011 +0000
@@ -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 <sys/cdefs.h>
 #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 <sys/param.h>
@@ -468,8 +468,12 @@
        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 &&



Home | Main Index | Thread Index | Old Index