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

Commit0bd5617

Browse files
committed
Always pfree strings returned by GetDatabasePath
Several places didn't do it, and in many cases it didn't matter becauseit would be a small allocation in a short-lived context; but otherplaces may accumulate a few (for example, in CreateDatabaseUsingFileCopy,one per tablespace). In most databases this is highly unlikely to bevery serious either, but it seems better to make the code consistent incase there's future copy-and-paste.The only case of actual concern seems to be the aforementioned routine,which is new with commit9c08aea, so there's no need to backpatch.As pointed out by Coverity.
1 parentf819020 commit0bd5617

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

‎src/backend/commands/dbcommands.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ CreateDatabaseUsingWalLog(Oid src_dboid, Oid dst_dboid,
217217
UnlockRelationId(&dstrelid,AccessShareLock);
218218
}
219219

220+
pfree(srcpath);
221+
pfree(dstpath);
220222
list_free_deep(rnodelist);
221223
}
222224

@@ -628,6 +630,8 @@ CreateDatabaseUsingFileCopy(Oid src_dboid, Oid dst_dboid, Oid src_tsid,
628630
(void)XLogInsert(RM_DBASE_ID,
629631
XLOG_DBASE_CREATE_FILE_COPY |XLR_SPECIAL_REL_UPDATE);
630632
}
633+
pfree(srcpath);
634+
pfree(dstpath);
631635
}
632636
table_endscan(scan);
633637
table_close(rel,AccessShareLock);
@@ -2128,6 +2132,9 @@ movedb(const char *dbname, const char *tblspcname)
21282132
/* Now it's safe to release the database lock */
21292133
UnlockSharedObjectForSession(DatabaseRelationId,db_id,0,
21302134
AccessExclusiveLock);
2135+
2136+
pfree(src_dbpath);
2137+
pfree(dst_dbpath);
21312138
}
21322139

21332140
/* Error cleanup callback for movedb */
@@ -2141,6 +2148,8 @@ movedb_failure_callback(int code, Datum arg)
21412148
dstpath=GetDatabasePath(fparms->dest_dboid,fparms->dest_tsoid);
21422149

21432150
(void)rmtree(dstpath, true);
2151+
2152+
pfree(dstpath);
21442153
}
21452154

21462155
/*
@@ -3051,6 +3060,9 @@ dbase_redo(XLogReaderState *record)
30513060
* We don't need to copy subdirectories
30523061
*/
30533062
copydir(src_path,dst_path, false);
3063+
3064+
pfree(src_path);
3065+
pfree(dst_path);
30543066
}
30553067
elseif (info==XLOG_DBASE_CREATE_WAL_LOG)
30563068
{
@@ -3063,6 +3075,7 @@ dbase_redo(XLogReaderState *record)
30633075
/* Create the database directory with the version file. */
30643076
CreateDirAndVersionFile(dbpath,xlrec->db_id,xlrec->tablespace_id,
30653077
true);
3078+
pfree(dbpath);
30663079
}
30673080
elseif (info==XLOG_DBASE_DROP)
30683081
{

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,7 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
10571057
}
10581058

10591059
SetDatabasePath(fullpath);
1060+
pfree(fullpath);
10601061

10611062
/*
10621063
* It's now possible to do real access to the system catalogs.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp