From 6753aca9ffa6a0569cf6cba2a47cda0e364f458c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 2 Sep 2024 11:25:58 +0300 Subject: Jingle: fix for occasional crash --- src/mir_core/src/tinyxml2_utils.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mir_core/src/tinyxml2_utils.cpp b/src/mir_core/src/tinyxml2_utils.cpp index 087e9d0230..c7351f16dc 100644 --- a/src/mir_core/src/tinyxml2_utils.cpp +++ b/src/mir_core/src/tinyxml2_utils.cpp @@ -71,9 +71,10 @@ MIR_CORE_DLL(int) XmlGetChildInt(const TiXmlElement *hXml, const char *key) MIR_CORE_DLL(const TiXmlElement*) XmlGetChildByTag(const TiXmlElement *hXml, const char *key, const char *attrName, const char *attrValue) { - for (auto *pChild : TiXmlFilter(hXml, key)) - if (pChild->Attribute(attrName, attrValue)) - return pChild; + if (hXml) + for (auto *pChild : TiXmlFilter(hXml, key)) + if (pChild->Attribute(attrName, attrValue)) + return pChild; return nullptr; } @@ -81,9 +82,11 @@ MIR_CORE_DLL(const TiXmlElement*) XmlGetChildByTag(const TiXmlElement *hXml, con MIR_CORE_DLL(int) XmlGetChildCount(const TiXmlElement *hXml) { int iCount = 0; - for (auto *it : TiXmlEnum(hXml)) { - UNREFERENCED_PARAMETER(it); - iCount++; - } + if (hXml) + for (auto *it : TiXmlEnum(hXml)) { + UNREFERENCED_PARAMETER(it); + iCount++; + } + return iCount; } -- cgit v1.2.3