From 8609c4ad5b2be1217ded66aa31738daa25b4a9c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Fri, 10 Apr 2020 15:39:31 +0200 Subject: when removing an image use the correct list ptr for presence verification This fixes an issues where calling `removeImage` would crash if the image was not present and the original list was not empty. --- CHANGELOG.md | 2 ++ src/mbgl/style/style_impl.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ceec9882f..5b333d4b00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,8 @@ The `symbolIntersectsTileEdges()` util in `mbgl::TilePlacement` now considers icon shift for the variable symbols with enabled icon-text-fit setting, thus providing more accurate results. +- [core] Correctly log a warning instead of crashing when a non-existent image is attempted to be removed. ([#16391](https://github.com/mapbox/mapbox-gl-native/pull/16391)) + ## maps-v1.5.1 ### 🐞 Bug fixes diff --git a/src/mbgl/style/style_impl.cpp b/src/mbgl/style/style_impl.cpp index 52f39b52d4..25cd122b81 100644 --- a/src/mbgl/style/style_impl.cpp +++ b/src/mbgl/style/style_impl.cpp @@ -293,7 +293,7 @@ void Style::Impl::removeImage(const std::string& id) { auto newImages = makeMutable(*images); auto found = std::find_if(newImages->begin(), newImages->end(), [&id](const auto& image) { return image->id == id; }); - if (found == images->end()) { + if (found == newImages->end()) { Log::Warning(Event::General, "Image '%s' is not present in style, cannot remove", id.c_str()); return; } -- cgit v1.2.1