summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2005-09-27 04:53:23 +0000
committerTom Lane2005-09-27 04:53:23 +0000
commit2ad783d51ec4fdb1a6fdf014dda0ae5effd56029 (patch)
treeb2540a760748311bf52a3c1d8fe283b485cb17be
parent0707af667b579890c6105626eb3a7ac44ca8ab7c (diff)
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.
-rw-r--r--src/port/strdup.c6
1 files changed, 4 insertions, 2 deletions
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;
}