vtkXMLTreeReader: protect against possible nullptr dereference
authorCory Quammen <cory.quammen@kitware.com>
Thu, 29 Sep 2022 17:10:00 +0000 (13:10 -0400)
committerMichael R. Crusoe <crusoe@debian.org>
Mon, 29 Apr 2024 14:16:28 +0000 (16:16 +0200)
Origin: upstream,https://gitlab.kitware.com/vtk/vtk/-/commit/72119ea71422d2892f2a0475fc282835310f8d9e
Forwarded: not-needed
Bug-Debian: https://bugs.debian.org/1031877

Vulnerability reported at
https://nvd.nist.gov/vuln/detail/CVE-2021-42521.

Gbp-Pq: Name 08_CVE-2021-42521.patch

IO/Infovis/vtkXMLTreeReader.cxx

index 02876f00cdefbe1093b6966b21cef5f20bb10336..946c7b9f272f3ad0574030fdc0d4cdf4bec65828 100644 (file)
@@ -217,6 +217,12 @@ int vtkXMLTreeReader::RequestData(
 
   // Get the root element node
   xmlNode* rootElement = xmlDocGetRootElement(doc);
+  if (!rootElement)
+  {
+    vtkErrorMacro(<< "Could not get root element of document.");
+    return 0;
+  }
+
   vtkXMLTreeReaderProcessElement(builder, -1, rootElement, this->ReadCharData, this->MaskArrays);
 
   xmlFreeDoc(doc);