Segfault when v2 ICC profiles do not contain parsable 'gamma/slope' info, fixes #5144
This commit is contained in:
@@ -255,14 +255,21 @@ bool get_RT_gamma_slope(cmsHPROFILE profile, double &gammatag, double &slopetag)
|
|||||||
modelDesc = utf32_to_utf8(buffer, count);
|
modelDesc = utf32_to_utf8(buffer, count);
|
||||||
#endif
|
#endif
|
||||||
if (!modelDesc.empty()) {
|
if (!modelDesc.empty()) {
|
||||||
std::size_t pos = modelDesc.find("g");
|
try {
|
||||||
std::size_t posmid = modelDesc.find("s");
|
std::size_t pos = modelDesc.find("g");
|
||||||
std::size_t posend = modelDesc.find("!");
|
std::size_t posmid = modelDesc.find("s");
|
||||||
std::string strgamma = modelDesc.substr(pos + 1, (posmid - pos));
|
std::size_t posend = modelDesc.find("!");
|
||||||
gammatag = std::stod(strgamma.c_str());
|
if (pos == std::string::npos || posmid == std::string::npos || posend == std::string::npos) {
|
||||||
std::string strslope = modelDesc.substr(posmid + 1, (posend - posmid));
|
return false;
|
||||||
slopetag = std::stod(strslope.c_str());
|
}
|
||||||
return true;
|
std::string strgamma = modelDesc.substr(pos + 1, (posmid - pos));
|
||||||
|
gammatag = std::stod(strgamma.c_str());
|
||||||
|
std::string strslope = modelDesc.substr(posmid + 1, (posend - posmid));
|
||||||
|
slopetag = std::stod(strslope.c_str());
|
||||||
|
return true;
|
||||||
|
} catch (std::invalid_argument &) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user