diff --git a/src/canonmn_int.cpp b/src/canonmn_int.cpp index 0c129921..50bb3676 100644 --- a/src/canonmn_int.cpp +++ b/src/canonmn_int.cpp @@ -2750,6 +2750,7 @@ namespace Exiv2 { if (pos == metadata->end() || pos->value().count() < 3 || pos->value().typeId() != unsignedShort || pos->value().toFloat(2) == 0.0F) { os << "Unknown Lens (" << lensType << ")"; + return os; } int const exifFlMin = static_cast(static_cast(pos->value().toLong(1)) / pos->value().toFloat(2)); @@ -2759,6 +2760,7 @@ namespace Exiv2 { pos = metadata->findKey(aperKey); if (pos == metadata->end() || pos->value().count() != 1 || pos->value().typeId() != unsignedShort) { os << "Unknown Lens (" << lensType << ")"; + return os; } auto exifAperMax = fnumber(canonEv(static_cast(pos->value().toLong(0)))); diff --git a/test/data/issue_1763_poc.exv b/test/data/issue_1763_poc.exv new file mode 100755 index 00000000..b1f540a0 Binary files /dev/null and b/test/data/issue_1763_poc.exv differ diff --git a/tests/bugfixes/github/test_issue_1763.py b/tests/bugfixes/github/test_issue_1763.py new file mode 100644 index 00000000..ea5f5484 --- /dev/null +++ b/tests/bugfixes/github/test_issue_1763.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +from system_tests import CaseMeta, path + +class CanonPrintCsLensTypeByMetadataNullIteratorDeref(metaclass=CaseMeta): + """ + Regression test for the bug described in: + https://github.com/Exiv2/exiv2/issues/1763 + """ + url = "https://github.com/Exiv2/exiv2/issues/1763" + + filename = path("$data_path/issue_1763_poc.exv") + commands = ["$exiv2 -Pt $filename"] + + stderr = [""] + retval = [0] + + def compare_stdout(self, i, command, got_stdout, expected_stdout): + # Check that it printed "Bad value" for the date. + self.assertIn("Unknown Lens (254)", got_stdout)