Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/ntp/dist/libopts/compat Check result of malloc ...



details:   https://anonhg.NetBSD.org/src/rev/a43b77dea8df
branches:  trunk
changeset: 769764:a43b77dea8df
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Sep 22 12:40:48 2011 +0000

description:
Check result of malloc (Maksymilian Arciemowicz)

diffstat:

 external/bsd/ntp/dist/libopts/compat/pathfind.c |  7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diffs (35 lines):

diff -r eaf2b59d328f -r a43b77dea8df external/bsd/ntp/dist/libopts/compat/pathfind.c
--- a/external/bsd/ntp/dist/libopts/compat/pathfind.c   Thu Sep 22 12:38:33 2011 +0000
+++ b/external/bsd/ntp/dist/libopts/compat/pathfind.c   Thu Sep 22 12:40:48 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pathfind.c,v 1.2 2010/12/04 23:08:34 christos Exp $    */
+/*     $NetBSD: pathfind.c,v 1.3 2011/09/22 12:40:48 christos Exp $    */
 
 /*  -*- Mode: C -*-  */
 
@@ -15,6 +15,7 @@
 /* Code: */
 
 #include "compat.h"
+
 #ifndef HAVE_PATHFIND
 #if defined(__windows__) && !defined(__CYGWIN__)
 char*
@@ -175,6 +176,8 @@
     } else {
         if (dot_path && dot_path[0]) {
             result = malloc( 2 + strlen( dot_path ) + strlen( string ) );
+           if (result == NULL)
+                   err(1, "malloc");
             strcpy( result, dot_path );
             result_len = strlen( result );
             if (result[result_len - 1] != '/') {
@@ -183,6 +186,8 @@
             }
         } else {
             result = malloc( 3 + strlen( string ) );
+           if (result == NULL)
+                   err(1, "malloc");
             result[0] = '.'; result[1] = '/'; result[2] = '\0';
             result_len = 2;
         }



Home | Main Index | Thread Index | Old Index