mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
Fix pfree crash in pg_get_role_ddl() and pg_get_database_ddl().
DatumGetArrayTypeP() can return a pointer into the tuple when the datum is stored as a short varlena, so pfree() on the result crashes. Use DatumGetArrayTypePCopy() to always get a palloc'd copy. Bug introduced in76e514ebb4anda4f774cf1c. Reported-by: Jeff Davis <pgsql@j-davis.com> Author: Satya Narlapuram <satya.narlapuram@gmail.com> Discussion: https://postgr.es/m/CAHg+QDdWtv9PKtPZEokwGCNtbv4MVnfYw5wMZrsEj4xizSNe5Q@mail.gmail.com
This commit is contained in:
@@ -480,7 +480,7 @@ pg_get_role_ddl_internal(Oid roleid, bool pretty, bool memberships)
|
||||
if (isnull)
|
||||
continue;
|
||||
|
||||
role_settings = DatumGetArrayTypeP(datum);
|
||||
role_settings = DatumGetArrayTypePCopy(datum);
|
||||
|
||||
deconstruct_array_builtin(role_settings, TEXTOID, &settings, &nulls, &nsettings);
|
||||
|
||||
@@ -1060,7 +1060,7 @@ pg_get_database_ddl_internal(Oid dbid, bool pretty,
|
||||
if (isnull)
|
||||
continue;
|
||||
|
||||
dbconfig = DatumGetArrayTypeP(datum);
|
||||
dbconfig = DatumGetArrayTypePCopy(datum);
|
||||
|
||||
deconstruct_array_builtin(dbconfig, TEXTOID, &settings, &nulls, &nsettings);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user