Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1aa1175

Browse files
committed
Fix pg_upgrade to remove malloc(0) call.
1 parent f25e5e5 commit 1aa1175

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-
int ntups;
4241
int tblnum;
4342
int i_spclocation;
4443

@@ -48,12 +47,15 @@ get_tablespace_paths(migratorContext *ctx)
4847
"WHERE spcname != '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)