mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
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.
This commit is contained in:
parent
4056efcfc1
commit
3772975f30
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 *
|
char *
|
||||||
strdup(char const * string)
|
strdup(const char *string)
|
||||||
{
|
{
|
||||||
char *nstr;
|
char *nstr;
|
||||||
|
|
||||||
nstr = strcpy((char *) malloc(strlen(string) + 1), string);
|
nstr = (char *) malloc(strlen(string) + 1);
|
||||||
|
if (nstr)
|
||||||
|
strcpy(nstr, string);
|
||||||
return nstr;
|
return nstr;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user