]> granicus.if.org Git - postgresql/commitdiff
Ensure xmlFree(NULL) is a no-op instead of a core dump. Per report from
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 10 Jun 2009 03:44:42 +0000 (03:44 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 10 Jun 2009 03:44:42 +0000 (03:44 +0000)
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

index 1bd758b1672a5e3c3c7a9b6457054fcbb390171d..e30fa2db39dcf1f839b65e426d5ed43faa1778f3 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.68.2.9 2009/06/08 21:32:50 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/xml.c,v 1.68.2.10 2009/06/10 03:44:42 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1325,7 +1325,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);
 }