Index: contrib/pg_upgrade/tablespace.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/pg_upgrade/tablespace.c,v
retrieving revision 1.1
diff -c -c -r1.1 tablespace.c
*** contrib/pg_upgrade/tablespace.c	12 May 2010 02:19:11 -0000	1.1
--- contrib/pg_upgrade/tablespace.c	16 Jun 2010 19:37:23 -0000
***************
*** 38,44 ****
  {
  	PGconn	   *conn = connectToServer(ctx, "template1", CLUSTER_OLD);
  	PGresult   *res;
- 	int			ntups;
  	int			tblnum;
  	int			i_spclocation;
  
--- 38,43 ----
***************
*** 48,59 ****
  							"WHERE	spcname != 'pg_default' AND "
  							"		spcname != 'pg_global'");
  
! 	ctx->num_tablespaces = ntups = PQntuples(res);
! 	ctx->tablespaces = (char **) pg_malloc(ctx, ntups * sizeof(char *));
  
  	i_spclocation = PQfnumber(res, "spclocation");
  
! 	for (tblnum = 0; tblnum < ntups; tblnum++)
  		ctx->tablespaces[tblnum] = pg_strdup(ctx,
  									 PQgetvalue(res, tblnum, i_spclocation));
  
--- 47,61 ----
  							"WHERE	spcname != 'pg_default' AND "
  							"		spcname != 'pg_global'");
  
! 	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 < ctx->num_tablespaces; tblnum++)
  		ctx->tablespaces[tblnum] = pg_strdup(ctx,
  									 PQgetvalue(res, tblnum, i_spclocation));
  
