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

Commitdf3f152

Browse files
committed
Don't assume free(NULL) is OK. Yes, I know ANSI C says it is.
1 parentc74dc12 commitdf3f152

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

‎src/backend/utils/init/miscinit.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.69 2001/06/06 17:07:46 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.70 2001/06/13 19:52:33 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -36,7 +36,6 @@
3636
#ifdefCYR_RECODE
3737
unsignedcharRecodeForwTable[128];
3838
unsignedcharRecodeBackTable[128];
39-
4039
#endif
4140

4241
ProcessingModeMode=InitProcessing;
@@ -82,7 +81,11 @@ IgnoreSystemIndexes(bool mode)
8281
void
8382
SetDatabasePath(constchar*path)
8483
{
85-
free(DatabasePath);
84+
if (DatabasePath)
85+
{
86+
free(DatabasePath);
87+
DatabasePath=NULL;
88+
}
8689
/* use strdup since this is done before memory contexts are set up */
8790
if (path)
8891
{
@@ -94,7 +97,12 @@ SetDatabasePath(const char *path)
9497
void
9598
SetDatabaseName(constchar*name)
9699
{
97-
free(DatabaseName);
100+
if (DatabaseName)
101+
{
102+
free(DatabaseName);
103+
DatabaseName=NULL;
104+
}
105+
/* use strdup since this is done before memory contexts are set up */
98106
if (name)
99107
{
100108
DatabaseName=strdup(name);
@@ -112,8 +120,6 @@ SetDataDir(const char *dir)
112120
char*new;
113121

114122
AssertArg(dir);
115-
if (DataDir)
116-
free(DataDir);
117123

118124
if (dir[0]!='/')
119125
{
@@ -155,6 +161,8 @@ SetDataDir(const char *dir)
155161
elog(FATAL,"out of memory");
156162
}
157163

164+
if (DataDir)
165+
free(DataDir);
158166
DataDir=new;
159167
}
160168

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp