Fixed access to uninit'd mem in repack_indexdef

If the tablespace is the last token in the indexdef, skip_ident returns a
pointer *after* the term zero, so garbage may end up after the statement.
This commit is contained in:
Daniele Varrazzo 2013-04-22 00:48:53 +01:00
parent 52e7761343
commit 109689586e

View File

@ -662,12 +662,13 @@ repack_indexdef(PG_FUNCTION_ARGS)
else
{
/* tablespace is to replace */
char *tmp;
char *tmp, *limit;
limit = strchr(stmt.options, '\0');
tmp = skip_const(index, stmt.options, " TABLESPACE", NULL);
appendStringInfoString(&str, stmt.options);
appendStringInfo(&str, " %s", NameStr(*tablespace));
tmp = skip_ident(index, tmp);
if (*tmp)
if (tmp < limit)
appendStringInfo(&str, " %s", tmp);
}
}