diff --git a/include/imageinfo.hpp b/include/imageinfo.hpp index 9b26df8..13db0bb 100644 --- a/include/imageinfo.hpp +++ b/include/imageinfo.hpp @@ -430,6 +430,10 @@ class ImageInfo { Error error_ = kNoError; }; +inline bool is_numeric(const std::string &str) { + return !str.empty() && std::all_of(str.begin(), str.end(), ::isdigit); +} + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // https://nokiatech.github.io/heif/technical.html @@ -701,6 +705,7 @@ inline bool try_hdr(ReadInterface &ri, size_t length, ImageInfo &info) { } auto y_str = resolution.substr(p0 + 1, p1 - p0 - 1); auto x_str = resolution.substr(p2 + 1); + if (!is_numeric(x_str) || !is_numeric(y_str)) return false; info = ImageInfo(kFormatHdr, "hdr", "hdr", "image/vnd.radiance"); info.set_size( // std::stol(x_str), //