Skip to content

Commit 4cf0048

Browse files
committed
[PGPRO-4074] Fix valgrind complain on garbage read in make_table_local.
1 parent 029b04e commit 4cf0048

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/ddl.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,17 +1542,22 @@ mtm_make_table_local(PG_FUNCTION_ARGS)
15421542
rel = table_openrv(rv, RowExclusiveLock);
15431543
if (rel != NULL)
15441544
{
1545-
char *tableName = get_rel_name(reloid);
1545+
char *table = get_rel_name(reloid);
1546+
Name tableName = (Name) palloc0(NAMEDATALEN);
15461547
Oid schemaid = get_rel_namespace(reloid);
1547-
char *schemaName = get_namespace_name(schemaid);
1548+
char *schema = get_namespace_name(schemaid);
1549+
Name schemaName = (Name) palloc0(NAMEDATALEN);
1550+
1551+
strncpy(NameStr(*schemaName), schema, NAMEDATALEN);
1552+
strncpy(NameStr(*tableName), table, NAMEDATALEN);
15481553

15491554
tupDesc = RelationGetDescr(rel);
15501555

15511556
/* Form a tuple. */
15521557
memset(nulls, false, sizeof(nulls));
15531558

1554-
values[Anum_mtm_local_tables_rel_schema - 1] = CStringGetDatum(schemaName);
1555-
values[Anum_mtm_local_tables_rel_name - 1] = CStringGetDatum(tableName);
1559+
values[Anum_mtm_local_tables_rel_schema - 1] = NameGetDatum(schemaName);
1560+
values[Anum_mtm_local_tables_rel_name - 1] = NameGetDatum(tableName);
15561561

15571562
tup = heap_form_tuple(tupDesc, values, nulls);
15581563

0 commit comments

Comments
 (0)