From c8f8e0c1f0a3687539a92169735845814e18c187 Mon Sep 17 00:00:00 2001 From: gcontini <1121667+gcontini@users.noreply.github.com> Date: 周六, 31 10月 2020 10:15:16 +0800 Subject: [PATCH] read dmi information segfault on windows --- src/library/os/linux/dmi_info.cpp | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/library/os/linux/dmi_info.cpp b/src/library/os/linux/dmi_info.cpp index e03cbd4..13dc3a7 100644 --- a/src/library/os/linux/dmi_info.cpp +++ b/src/library/os/linux/dmi_info.cpp @@ -1,7 +1,7 @@ #include "../../base/file_utils.hpp" #include "../../base/string_utils.h" - +#include "../../base/logger.h" #include "../dmi_info.hpp" namespace license { @@ -10,8 +10,9 @@ DmiInfo::DmiInfo() { try { m_bios_vendor = toupper_copy(trim_copy(get_file_contents("/sys/class/dmi/id/sys_vendor", 256))); - - } catch (...) { + } catch (std::string &e) { + m_bios_vendor = ""; + LOG_DEBUG("Can not read sys_vendor", e); } try { m_bios_description = toupper_copy(trim_copy(get_file_contents("/sys/class/dmi/id/modalias", 256))); @@ -19,7 +20,9 @@ if (last_char == '\r' || last_char == '\n') { m_bios_description = m_bios_description.erase(m_bios_description.length() - 1); } - } catch (...) { + } catch (std::string &e) { + m_bios_description = ""; + LOG_DEBUG("Can not read bios_description", e); } try { m_sys_vendor = get_file_contents("/sys/class/dmi/id/sys_vendor", 256); @@ -27,7 +30,9 @@ if (last_char == '\r' || last_char == '\n') { m_sys_vendor = m_sys_vendor.erase(m_sys_vendor.length() - 1); } - } catch (...) { + } catch (std::string &e) { + m_sys_vendor = ""; + LOG_DEBUG("Can not read bios_description", e); } } -- Gitblit v1.9.1