From 4a8e7510e1ee83a7b627ee02d5f990efc2b80857 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 27 Feb 2021 15:29:14 +0700 Subject: [PATCH] #2123 Ignore regex exception. --- src/hw/dmi/DmiMemory.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/hw/dmi/DmiMemory.cpp b/src/hw/dmi/DmiMemory.cpp index 735af286..883c89b5 100644 --- a/src/hw/dmi/DmiMemory.cpp +++ b/src/hw/dmi/DmiMemory.cpp @@ -230,14 +230,16 @@ void xmrig::DmiMemory::setId(const char *slot, const char *bank) m_slot = slot; m_bank = bank; - std::cmatch cm; - if (std::regex_match(slot, cm, std::regex("^Channel([A-Z])[-_]DIMM(\\d+)$", std::regex_constants::icase))) { - m_id = fmt::format(kIdFormat, cm.str(1), cm.str(2)).c_str(); - } - else if (std::regex_search(bank, cm, std::regex("CHANNEL ([A-Z])$"))) { - std::cmatch cm2; - if (std::regex_match(slot, cm2, std::regex("^DIMM (\\d+)$"))) { - m_id = fmt::format(kIdFormat, cm.str(1), cm2.str(1)).c_str(); + try { + std::cmatch cm; + if (std::regex_match(slot, cm, std::regex("^Channel([A-Z])[-_]DIMM(\\d+)$", std::regex_constants::icase))) { + m_id = fmt::format(kIdFormat, cm.str(1), cm.str(2)).c_str(); } - } + else if (std::regex_search(bank, cm, std::regex("CHANNEL ([A-Z])$"))) { + std::cmatch cm2; + if (std::regex_match(slot, cm2, std::regex("^DIMM (\\d+)$"))) { + m_id = fmt::format(kIdFormat, cm.str(1), cm2.str(1)).c_str(); + } + } + } catch (...) {} }