diff options
author | Bruce Momjian <bruce@momjian.us> | 2010-06-16 19:43:11 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2010-06-16 19:43:11 +0000 |
commit | 1aa117506df38e2ea4efcdffd9ac18b93399aa6b (patch) | |
tree | 051818a7757493448bcd3463b2cb755df93bc938 /contrib/pg_upgrade/tablespace.c | |
parent | f25e5e5d475f42fa8a52f9941c08286fc2bbfb4a (diff) | |
download | postgresql-1aa117506df38e2ea4efcdffd9ac18b93399aa6b.tar.gz postgresql-1aa117506df38e2ea4efcdffd9ac18b93399aa6b.zip |
Fix pg_upgrade to remove malloc(0) call.
Diffstat (limited to 'contrib/pg_upgrade/tablespace.c')
-rw-r--r-- | contrib/pg_upgrade/tablespace.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/contrib/pg_upgrade/tablespace.c b/contrib/pg_upgrade/tablespace.c index 302eb0d1cb1..9eda197f06e 100644 --- a/contrib/pg_upgrade/tablespace.c +++ b/contrib/pg_upgrade/tablespace.c @@ -38,7 +38,6 @@ get_tablespace_paths(migratorContext *ctx) { PGconn *conn = connectToServer(ctx, "template1", CLUSTER_OLD); PGresult *res; - int ntups; int tblnum; int i_spclocation; @@ -48,12 +47,15 @@ get_tablespace_paths(migratorContext *ctx) "WHERE spcname != 'pg_default' AND " " spcname != 'pg_global'"); - ctx->num_tablespaces = ntups = PQntuples(res); - ctx->tablespaces = (char **) pg_malloc(ctx, ntups * sizeof(char *)); + if ((ctx->num_tablespaces = PQntuples(res)) != 0) + ctx->tablespaces = (char **) pg_malloc(ctx, + ctx->num_tablespaces * sizeof(char *)); + else + ctx->tablespaces = NULL; i_spclocation = PQfnumber(res, "spclocation"); - for (tblnum = 0; tblnum < ntups; tblnum++) + for (tblnum = 0; tblnum < ctx->num_tablespaces; tblnum++) ctx->tablespaces[tblnum] = pg_strdup(ctx, PQgetvalue(res, tblnum, i_spclocation)); |