From: Tom Lane Date: Tue, 27 Sep 2005 04:53:23 +0000 (+0000) Subject: Fix our version of strdup() to adhere to the standard semantics for X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=2ad783d51ec4fdb1a6fdf014dda0ae5effd56029;p=users%2Fbernd%2Fpostgres.git Fix our version of strdup() to adhere to the standard semantics for out-of-memory --- that is, return NULL rather than dumping core. Noted by Qingqing Zhou. --- diff --git a/src/port/strdup.c b/src/port/strdup.c index 70a9faf2ee..3facc4a77b 100644 --- a/src/port/strdup.c +++ b/src/port/strdup.c @@ -19,10 +19,12 @@ char * -strdup(char const * string) +strdup(const char *string) { char *nstr; - nstr = strcpy((char *) malloc(strlen(string) + 1), string); + nstr = (char *) malloc(strlen(string) + 1); + if (nstr) + strcpy(nstr, string); return nstr; }