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

Commitacfaa59

Browse files
committed
pg_dump: Fix some minor memory leaks
Although we often don't care about freeing all memory in pg_dump,these functions already freed the same memory in other code paths, sowe might as well do it consistently.found by Coverity
1 parent5cd72c7 commitacfaa59

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3169,7 +3169,7 @@ getCollations(Archive *fout, int *numCollations)
31693169
PGresult*res;
31703170
intntups;
31713171
inti;
3172-
PQExpBufferquery=createPQExpBuffer();
3172+
PQExpBufferquery;
31733173
CollInfo*collinfo;
31743174
inti_tableoid;
31753175
inti_oid;
@@ -3184,6 +3184,8 @@ getCollations(Archive *fout, int *numCollations)
31843184
returnNULL;
31853185
}
31863186

3187+
query=createPQExpBuffer();
3188+
31873189
/*
31883190
* find all collations, including builtin collations; we filter out
31893191
* system-defined collations at dump-out time.
@@ -6167,7 +6169,7 @@ getTSParsers(Archive *fout, int *numTSParsers)
61676169
PGresult*res;
61686170
intntups;
61696171
inti;
6170-
PQExpBufferquery=createPQExpBuffer();
6172+
PQExpBufferquery;
61716173
TSParserInfo*prsinfo;
61726174
inti_tableoid;
61736175
inti_oid;
@@ -6186,6 +6188,8 @@ getTSParsers(Archive *fout, int *numTSParsers)
61866188
returnNULL;
61876189
}
61886190

6191+
query=createPQExpBuffer();
6192+
61896193
/*
61906194
* find all text search objects, including builtin ones; we filter out
61916195
* system-defined objects at dump-out time.
@@ -6257,7 +6261,7 @@ getTSDictionaries(Archive *fout, int *numTSDicts)
62576261
PGresult*res;
62586262
intntups;
62596263
inti;
6260-
PQExpBufferquery=createPQExpBuffer();
6264+
PQExpBufferquery;
62616265
TSDictInfo*dictinfo;
62626266
inti_tableoid;
62636267
inti_oid;
@@ -6274,6 +6278,8 @@ getTSDictionaries(Archive *fout, int *numTSDicts)
62746278
returnNULL;
62756279
}
62766280

6281+
query=createPQExpBuffer();
6282+
62776283
/* Make sure we are in proper schema */
62786284
selectSourceSchema(fout,"pg_catalog");
62796285

@@ -6340,7 +6346,7 @@ getTSTemplates(Archive *fout, int *numTSTemplates)
63406346
PGresult*res;
63416347
intntups;
63426348
inti;
6343-
PQExpBufferquery=createPQExpBuffer();
6349+
PQExpBufferquery;
63446350
TSTemplateInfo*tmplinfo;
63456351
inti_tableoid;
63466352
inti_oid;
@@ -6356,6 +6362,8 @@ getTSTemplates(Archive *fout, int *numTSTemplates)
63566362
returnNULL;
63576363
}
63586364

6365+
query=createPQExpBuffer();
6366+
63596367
/* Make sure we are in proper schema */
63606368
selectSourceSchema(fout,"pg_catalog");
63616369

@@ -6415,7 +6423,7 @@ getTSConfigurations(Archive *fout, int *numTSConfigs)
64156423
PGresult*res;
64166424
intntups;
64176425
inti;
6418-
PQExpBufferquery=createPQExpBuffer();
6426+
PQExpBufferquery;
64196427
TSConfigInfo*cfginfo;
64206428
inti_tableoid;
64216429
inti_oid;
@@ -6431,6 +6439,8 @@ getTSConfigurations(Archive *fout, int *numTSConfigs)
64316439
returnNULL;
64326440
}
64336441

6442+
query=createPQExpBuffer();
6443+
64346444
/* Make sure we are in proper schema */
64356445
selectSourceSchema(fout,"pg_catalog");
64366446

@@ -9467,16 +9477,18 @@ dumpCast(Archive *fout, CastInfo *cast)
94679477
appendPQExpBuffer(defqry,"WITH INOUT");
94689478
break;
94699479
caseCOERCION_METHOD_FUNCTION:
9480+
{
9481+
char*fsig=format_function_signature(fout,funcInfo, true);
94709482

94719483
/*
94729484
* Always qualify the function name, in case it is not in
94739485
* pg_catalog schema (format_function_signature won't qualify it).
94749486
*/
9475-
appendPQExpBuffer(defqry,"WITH FUNCTION %s.",
9476-
fmtId(funcInfo->dobj.namespace->dobj.name));
9477-
appendPQExpBuffer(defqry,"%s",
9478-
format_function_signature(fout,funcInfo, true));
9487+
appendPQExpBuffer(defqry,"WITH FUNCTION %s.%s",
9488+
fmtId(funcInfo->dobj.namespace->dobj.name),fsig);
9489+
free(fsig);
94799490
break;
9491+
}
94809492
default:
94819493
write_msg(NULL,"WARNING: bogus value in pg_cast.castmethod field\n");
94829494
}

‎src/bin/pg_dump/pg_dumpall.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,12 +1525,17 @@ makeAlterConfigCommand(PGconn *conn, const char *arrayitem,
15251525
{
15261526
char*pos;
15271527
char*mine;
1528-
PQExpBufferbuf=createPQExpBuffer();
1528+
PQExpBufferbuf;
15291529

15301530
mine=pg_strdup(arrayitem);
15311531
pos=strchr(mine,'=');
15321532
if (pos==NULL)
1533+
{
1534+
free(mine);
15331535
return;
1536+
}
1537+
1538+
buf=createPQExpBuffer();
15341539

15351540
*pos=0;
15361541
appendPQExpBuffer(buf,"ALTER %s %s ",type,fmtId(name));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp