Skip to content

Commit 3772975

Browse files
committed
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.
1 parent 4056efc commit 3772975

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/port/strdup.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/port/strdup.c,v 1.7 2005/07/28 04:03:14 tgl Exp $
11+
* $PostgreSQL: pgsql/src/port/strdup.c,v 1.8 2005/09/27 04:53:23 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -19,10 +19,12 @@
1919

2020

2121
char *
22-
strdup(char const * string)
22+
strdup(const char *string)
2323
{
2424
char *nstr;
2525

26-
nstr = strcpy((char *) malloc(strlen(string) + 1), string);
26+
nstr = (char *) malloc(strlen(string) + 1);
27+
if (nstr)
28+
strcpy(nstr, string);
2729
return nstr;
2830
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy