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

Commit1aa1175

Browse files
committed
Fix pg_upgrade to remove malloc(0) call.
1 parentf25e5e5 commit1aa1175

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

‎contrib/pg_upgrade/tablespace.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ get_tablespace_paths(migratorContext *ctx)
3838
{
3939
PGconn*conn=connectToServer(ctx,"template1",CLUSTER_OLD);
4040
PGresult*res;
41-
intntups;
4241
inttblnum;
4342
inti_spclocation;
4443

@@ -48,12 +47,15 @@ get_tablespace_paths(migratorContext *ctx)
4847
"WHEREspcname != 'pg_default' AND "
4948
"spcname != 'pg_global'");
5049

51-
ctx->num_tablespaces=ntups=PQntuples(res);
52-
ctx->tablespaces= (char**)pg_malloc(ctx,ntups*sizeof(char*));
50+
if ((ctx->num_tablespaces=PQntuples(res))!=0)
51+
ctx->tablespaces= (char**)pg_malloc(ctx,
52+
ctx->num_tablespaces*sizeof(char*));
53+
else
54+
ctx->tablespaces=NULL;
5355

5456
i_spclocation=PQfnumber(res,"spclocation");
5557

56-
for (tblnum=0;tblnum<ntups;tblnum++)
58+
for (tblnum=0;tblnum<ctx->num_tablespaces;tblnum++)
5759
ctx->tablespaces[tblnum]=pg_strdup(ctx,
5860
PQgetvalue(res,tblnum,i_spclocation));
5961

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp