From 65afd7da0bb76ad1c1328d0b375f40e7f4962b0c Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Sat, 1 Feb 2025 08:06:59 +0100 Subject: [PATCH] pofParser: getData/getLength: check if section exists: return data/length or null/-1 --- src/pofParser.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pofParser.cpp b/src/pofParser.cpp index 1eccf27..753d68c 100644 --- a/src/pofParser.cpp +++ b/src/pofParser.cpp @@ -32,14 +32,20 @@ uint8_t *POFParser::getData(const std::string §ion_name) { if (section_name == "") return (uint8_t*)_bit_data.data(); - return mem_section[section_name].data; + auto section = mem_section.find(section_name); + if (section == mem_section.end()) + return NULL; + return (*section).second.data; } int POFParser::getLength(const std::string §ion_name) { if (section_name == "") return _bit_length; - return mem_section[section_name].len; + auto section = mem_section.find(section_name); + if (section == mem_section.end()) + return -1; + return (*section).second.len; } void POFParser::displayHeader()