From f749d926bd9796badee2efd1ee1da5905d6fd38d Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 14 May 2007 19:04:24 -0700 Subject: Replace copystring() with strdup() calls Also solves Coverity #924: Function copystring: Pointer "src" dereferenced before NULL check --- process.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/process.c b/process.c index c235cb9..aab8882 100644 --- a/process.c +++ b/process.c @@ -83,7 +83,6 @@ static char *stdout_filename = "(stdout)"; /* for messages */ static char *Yes = "yes"; /* for messages */ static char *No = "no"; /* for messages */ -static char *copystring ( char *src ); static int binaryEqual ( char *a, char *b, unsigned len ); static void prefix ( char *fn, int n ); static void badcommandline ( char *cmd ); @@ -230,18 +229,7 @@ static int original_umask = 0; /* for restoring */ * private utility procedures */ -static char *copystring (src) - char *src; -{ - int len = strlen (src); - char *cp; - - if (!src) return NULL; - cp = malloc (len + 1); - if (cp) - strcpy (cp, src); - return cp; -} +#define copystring(s) ( s != NULL ? strdup(s) : NULL ) static int binaryEqual (a, b, len) -- cgit v1.2.1