BUG #18787: pointer te->defn not checked for NULL - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #18787: pointer te->defn not checked for NULL
Date
Msg-id 18787-676496fef9742cab@postgresql.org
Whole thread Raw
Responses Re: BUG #18787: pointer te->defn not checked for NULL
List pgsql-bugs
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)
        {


pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #18786: Pointer bmr.rel, dereferenced by passing as 1st parameter to function is checked for NULL later
Next
From: Tom Lane
Date:
Subject: Re: BUG #18787: pointer te->defn not checked for NULL