Source-Changes-HG archive

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

[src/trunk]: src/dist/dhcp/dst check the result of malloc (Maksymilian Arciem...



details:   https://anonhg.NetBSD.org/src/rev/eaf2b59d328f
branches:  trunk
changeset: 769763:eaf2b59d328f
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Sep 22 12:38:33 2011 +0000

description:
check the result of malloc (Maksymilian Arciemowicz)

diffstat:

 dist/dhcp/dst/prandom.c |  5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diffs (27 lines):

diff -r 48329a6f09c5 -r eaf2b59d328f dist/dhcp/dst/prandom.c
--- a/dist/dhcp/dst/prandom.c   Thu Sep 22 08:42:53 2011 +0000
+++ b/dist/dhcp/dst/prandom.c   Thu Sep 22 12:38:33 2011 +0000
@@ -1,5 +1,5 @@
 #ifndef LINT
-static const char rcsid[] = "$Header: /cvsroot/src/dist/dhcp/dst/Attic/prandom.c,v 1.6 2010/01/26 19:11:00 drochner Exp $";
+static const char rcsid[] = "$Header: /cvsroot/src/dist/dhcp/dst/Attic/prandom.c,v 1.7 2011/09/22 12:38:33 christos Exp $";
 #endif
 /*
  * Portions Copyright (c) 1995-1998 by Trusted Information Systems, Inc.
@@ -26,6 +26,7 @@
 #include <fcntl.h>
 #include <time.h>
 #include <dirent.h>
+#include <err.h>
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/time.h>
@@ -454,6 +455,8 @@
        if (hash->step > 1) {   /* if using subset of input data */
                tmp_size = size / hash->step + 2;
                abuf = tp = malloc(tmp_size);
+               if (tp == NULL)
+                       err(1, "malloc");
                tmp = tp;
                for (cnt = 0, i = hash->curr; i < size; i += hash->step, cnt++)
                        *(tp++) = input[i];



Home | Main Index | Thread Index | Old Index