Fix-misuse-of-volatile.patch

application/octet-stream

Filename: Fix-misuse-of-volatile.patch
Type: application/octet-stream
Part: 0
Message: Re: BUG #18943: Return value of a function 'xmlBufferCreate' isdereferenced at xpath.c:177 without checking for NUL

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/backend/utils/adt/xml.c 6 6
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index 2c8d5a81b75..dd3270a0782 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -529,7 +529,7 @@ xmltext(PG_FUNCTION_ARGS)
 #ifdef USE_LIBXML
 	text	   *arg = PG_GETARG_TEXT_PP(0);
 	text	   *result;
-	volatile xmlChar *xmlbuf = NULL;
+	xmlChar	   *volatile xmlbuf = NULL;
 	PgXmlErrorContext *xmlerrcxt;
 
 	/* First we gotta spin up some error handling. */
@@ -544,19 +544,19 @@ xmltext(PG_FUNCTION_ARGS)
 						"could not allocate xmlChar");
 
 		result = cstring_to_text_with_len((const char *) xmlbuf,
-										  xmlStrlen((const xmlChar *) xmlbuf));
+										  xmlStrlen(xmlbuf));
 	}
 	PG_CATCH();
 	{
 		if (xmlbuf)
-			xmlFree((xmlChar *) xmlbuf);
+			xmlFree(xmlbuf);
 
 		pg_xml_done(xmlerrcxt, true);
 		PG_RE_THROW();
 	}
 	PG_END_TRY();
 
-	xmlFree((xmlChar *) xmlbuf);
+	xmlFree(xmlbuf);
 	pg_xml_done(xmlerrcxt, false);
 
 	PG_RETURN_XML_P(result);
@@ -4247,7 +4247,7 @@ xml_xmlnodetoxmltype(xmlNodePtr cur, PgXmlErrorContext *xmlerrcxt)
 	}
 	else
 	{
-		volatile xmlChar *str = NULL;
+		xmlChar *volatile str = NULL;
 
 		PG_TRY();
 		{
@@ -4267,7 +4267,7 @@ xml_xmlnodetoxmltype(xmlNodePtr cur, PgXmlErrorContext *xmlerrcxt)
 		PG_FINALLY();
 		{
 			if (str)
-				xmlFree((xmlChar *) str);
+				xmlFree(str);
 		}
 		PG_END_TRY();
 	}