From 89f30c6ceb695571b04e9b70b8bccf725183bab4 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 10 Jun 2009 03:44:35 +0000 Subject: [PATCH] Ensure xmlFree(NULL) is a no-op instead of a core dump. Per report from Sergey Burladyan, there are at least some dank corners of libxml2 that assume this behavior, even though their published documentation suggests they shouldn't. This is only really a live problem in 8.3, but the code is still there for possible debugging use in HEAD, so patch both branches. --- src/backend/utils/adt/xml.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index f6292b9137..9b34a7abbc 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -1293,7 +1293,9 @@ xml_repalloc(void *ptr, size_t size) static void xml_pfree(void *ptr) { - pfree(ptr); + /* At least some parts of libxml assume xmlFree(NULL) is allowed */ + if (ptr) + pfree(ptr); } -- 2.39.5