diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-09-27 04:53:23 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-09-27 04:53:23 +0000 |
commit | 3772975f308c430d392bae3f0c3c4d68966d26d2 (patch) | |
tree | 780c42ed06aec2b6c2a78467d47a7eecc4b28a2d /src | |
parent | 4056efcfc15b3f66427f61f3f06b155f9bc6b516 (diff) | |
download | postgresql-3772975f308c430d392bae3f0c3c4d68966d26d2.tar.gz postgresql-3772975f308c430d392bae3f0c3c4d68966d26d2.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/port/strdup.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/port/strdup.c b/src/port/strdup.c index 2854b660110..22f842da16d 100644 --- a/src/port/strdup.c +++ b/src/port/strdup.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/port/strdup.c,v 1.7 2005/07/28 04:03:14 tgl Exp $ + * $PostgreSQL: pgsql/src/port/strdup.c,v 1.8 2005/09/27 04:53:23 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -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; } |