From f47eb15d2b83d5cdd8904de9416175c36682dd92 Mon Sep 17 00:00:00 2001 From: Ingo Weyrich Date: Sun, 19 Sep 2021 10:25:53 +0200 Subject: [PATCH] fix crash in dehaze, fixes #6364 --- rtengine/ipdehaze.cc | 4 ++++ 1 file changed, 4 insertions(+) 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];