[mapguide-commits] r10293 - branches/4.0/MgDev/Common/PlatformBase/MapLayer

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Wed Nov 18 07:43:39 PST 2026


Author: jng
Date: 2026-11-18 07:43:39 -0800 (Wed, 18 Nov 2026)
New Revision: 10293

Modified:
   branches/4.0/MgDev/Common/PlatformBase/MapLayer/SelectionBase.cpp
Log:
Gracefully handle malformed XML in MgSelection (actual fix). Fixes #2904

Modified: branches/4.0/MgDev/Common/PlatformBase/MapLayer/SelectionBase.cpp
===================================================================
--- branches/4.0/MgDev/Common/PlatformBase/MapLayer/SelectionBase.cpp	2026-11-18 15:27:17 UTC (rev 10292)
+++ branches/4.0/MgDev/Common/PlatformBase/MapLayer/SelectionBase.cpp	2026-11-18 15:43:39 UTC (rev 10293)
@@ -118,6 +118,15 @@
     xmlUtil.ParseString(text.c_str());
 
     DOMElement* root = xmlUtil.GetRootNode();
+    if (NULL == root)
+    {
+        // A document the parser rejected has no document element, and GetRootNode() guards only
+        // the document, not the element it hands back: reading that root's children was a NULL
+        // dereference that took the whole process down with it. FromXml is given a selection
+        // string a client supplies, so this has to be an exception the caller can handle.
+        throw new MgException(MgExceptionCodes::MgXmlParserException, L"MgSelectionBase.FromXml",
+            __LINE__, __WFILE__, NULL, L"", NULL);
+    }
     DOMNode* layerChild = MgXmlUtil::GetFirstChild(root);
     while(0 != layerChild)
     {



More information about the mapguide-commits mailing list