diff --git a/rtengine/ipdehaze.cc b/rtengine/ipdehaze.cc index 6ae8be27b..cb860cfb9 100644 --- a/rtengine/ipdehaze.cc +++ b/rtengine/ipdehaze.cc @@ -210,6 +210,10 @@ float estimate_ambient_light(const array2D &R, const array2D &G, c } } + if (p.size() == 0) { + return 0.f; + } + const int pos = p.size() * 0.95; std::nth_element(p.begin(), p.begin() + pos, p.end()); darklim = p[pos];