Skip to content

Commit 5efa454

Browse files
committed
fix: ImageSpec::metadata_val improved safety (AcademySoftwareFoundation#5096)
If certain camera metadata was mangled and or otherwise wasn't one of the known metadata names, it could run off the end of the list and dereference a null pointer. Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 8c40f3b commit 5efa454

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/libOpenImageIO/formatspec.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -861,15 +861,15 @@ ImageSpec::metadata_val(const ParamValue& p, bool human)
861861
if (human) {
862862
const ExplanationTableEntry* exp = nullptr;
863863
for (const auto& e : explanation)
864-
if (Strutil::iequals(e.oiioname, p.name()))
864+
if (e.oiioname && Strutil::iequals(e.oiioname, p.name()))
865865
exp = &e;
866866
std::string nice;
867867
if (!exp && Strutil::istarts_with(p.name(), "Canon:")) {
868868
for (const auto& e : canon_explanation_table())
869869
if (Strutil::iequals(e.oiioname, p.name()))
870870
exp = &e;
871871
}
872-
if (exp)
872+
if (exp && exp->explainer)
873873
nice = exp->explainer(p, exp->extradata);
874874
if (ptype.elementtype() == TypeRational) {
875875
for (int i = 0, n = (int)ptype.numelements(); i < n; ++i) {

0 commit comments

Comments
 (0)