missing assert in makeString

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Subject: missing assert in makeString
Date: 2025-02-19 06:31:18
Message-ID: CAFj8pRC24FEBNfTUrDgAK8f2nqDVvzWCuq=R=T19nUjL9GuLBA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

I investigated the crashes in "xmlnamespaces to xmlelement" patch and it
looks like there was a badly used makeString function. The argument should
not be null, elsewhere serialization to string fails - and deserialization
doesn't support this case.

https://cirrus-ci.com/task/6543809942650880

I propose to add an assert there like (make check-world passed)

diff --git a/src/backend/nodes/value.c b/src/backend/nodes/value.c
index 5a8c1ce2478..620a97ece79 100644
--- a/src/backend/nodes/value.c
+++ b/src/backend/nodes/value.c
@@ -64,6 +64,8 @@ makeString(char *str)
{
String *v = makeNode(String);

+ Assert(str);
+
v->sval = str;
return v;
}

Regards

Pavel

Attachment Content-Type Size
0001-initial.patch text/x-patch 568 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2025-02-19 06:48:53 Re: missing assert in makeString
Previous Message Daniil Davydov 2025-02-19 06:13:07 Re: Forbid to DROP temp tables of other sessions