The following bug has been logged on the website:
Bug reference: 18787
Logged by: Daniel Elishakov
Email address: dan-eli@mail.ru
PostgreSQL version: 16.6
Operating system: ubuntu 20.04
Description:
Here is a patch fixing the issue. I think that NULL check is needed here
diff --git a/src/bin/pg_dump/pg_backup_archiver.c
b/src/bin/pg_dump/pg_backup_archiver.c
index 958f88d420..ebb7eca43c 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -3654,7 +3654,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool
isData)
if (!ropt->noOwner &&
(!ropt->use_setsessauth ||
(strcmp(te->desc, "SCHEMA") == 0 &&
- strncmp(te->defn, "--", 2) == 0)) &&
+ (te->defn && strncmp(te->defn, "--", 2) == 0))) &&
te->owner && strlen(te->owner) > 0 &&
te->dropStmt && strlen(te->dropStmt) > 0)
{