From b03c74d4335b9c09add9abf8a7a6cd92fee78293 Mon Sep 17 00:00:00 2001 From: netliomax25-code Date: Mon, 1 Jun 2026 23:49:19 +0530 Subject: [PATCH 1/2] catch stoul exceptions in CanonMakerNote print0x000a/print0x000c (cherry picked from commit f62ab78423f23b74a89a63c74dcaf97813852ed7) --- src/canonmn_int.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/canonmn_int.cpp b/src/canonmn_int.cpp index 6bc3b7ac83..c272822a0f 100644 --- a/src/canonmn_int.cpp +++ b/src/canonmn_int.cpp @@ -2714,8 +2714,14 @@ std::ostream& CanonMakerNote::print0x0008(std::ostream& os, const Value& value, } std::ostream& CanonMakerNote::print0x000a(std::ostream& os, const Value& value, const ExifData*) { - uint32_t l = std::stoul(value.toString()); - return os << stringFormat("{:04x}{:05}", (l >> 16) & 0xFFFF, l & 0xFFFF); + try { + uint32_t l = std::stoul(value.toString()); + return os << stringFormat("{:04x}{:05}", (l >> 16) & 0xFFFF, l & 0xFFFF); + } catch (const std::invalid_argument&) { + return os << value; + } catch (const std::out_of_range&) { + return os << value; + } } std::ostream& CanonMakerNote::print0x000c(std::ostream& os, const Value& value, const ExifData* exifData) { @@ -2727,8 +2733,14 @@ std::ostream& CanonMakerNote::print0x000c(std::ostream& os, const Value& value, auto pos = exifData->findKey(key); // if model is EOS D30 if (pos != exifData->end() && pos->value().count() == 1 && pos->value().toInt64() == 0x01140000) { - uint32_t l = std::stoul(value.toString()); - return os << stringFormat("{:04x}{:05}", (l >> 16) & 0xFFFF, l & 0xFFFF); + try { + uint32_t l = std::stoul(value.toString()); + return os << stringFormat("{:04x}{:05}", (l >> 16) & 0xFFFF, l & 0xFFFF); + } catch (const std::invalid_argument&) { + return os << value; + } catch (const std::out_of_range&) { + return os << value; + } } return os << value; } From 00a13a5d74d3ef70e6657131036cf2ba54d7367e Mon Sep 17 00:00:00 2001 From: netliomax25-code Date: Mon, 22 Jun 2026 16:52:04 +0530 Subject: [PATCH 2/2] catch std::logic_error to cover both stoul failure modes (cherry picked from commit 610133a42ec8f5c988a6ae64917b4348e7558bad) --- src/canonmn_int.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/canonmn_int.cpp b/src/canonmn_int.cpp index c272822a0f..a66d0c2195 100644 --- a/src/canonmn_int.cpp +++ b/src/canonmn_int.cpp @@ -2717,9 +2717,7 @@ std::ostream& CanonMakerNote::print0x000a(std::ostream& os, const Value& value, try { uint32_t l = std::stoul(value.toString()); return os << stringFormat("{:04x}{:05}", (l >> 16) & 0xFFFF, l & 0xFFFF); - } catch (const std::invalid_argument&) { - return os << value; - } catch (const std::out_of_range&) { + } catch (const std::logic_error&) { return os << value; } } @@ -2736,9 +2734,7 @@ std::ostream& CanonMakerNote::print0x000c(std::ostream& os, const Value& value, try { uint32_t l = std::stoul(value.toString()); return os << stringFormat("{:04x}{:05}", (l >> 16) & 0xFFFF, l & 0xFFFF); - } catch (const std::invalid_argument&) { - return os << value; - } catch (const std::out_of_range&) { + } catch (const std::logic_error&) { return os << value; } }