Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3772975

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 parent4056efc commit3772975

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(charconst*string)
22+
strdup(constchar*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
returnnstr;
2830
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp