From 0d97a2bd575c1951dc4ebf20b2d9d6f7c1192a72 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Wed, 20 Sep 2023 17:36:38 -0700 Subject: [PATCH] closeSession: actually remove elements from sessions_ std::remove_if consolidates the non-removed elements at the start of the vector, but it doesn't change the vector's size. After upgrading libc++, std::remove_if is [[nodiscard]], so this bug causes a compiler error. Bug: 175635923 Test: m android.hardware.drm-service.castkey Change-Id: Ie9734e616f0f93e290cd61f929af04598f236ee7 --- cast_auth/mediadrm/SessionLibrary.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cast_auth/mediadrm/SessionLibrary.cpp b/cast_auth/mediadrm/SessionLibrary.cpp index f881c26..8d56660 100644 --- a/cast_auth/mediadrm/SessionLibrary.cpp +++ b/cast_auth/mediadrm/SessionLibrary.cpp @@ -29,10 +29,11 @@ std::vector SessionLibrary::createSession() { void SessionLibrary::closeSession(const std::vector& session) { std::lock_guard guard(session_lock_); - std::remove_if(sessions_.begin(), sessions_.end(), - [&session](const std::vector& e) { - return std::equal(e.begin(), e.end(), session.begin()); - }); + sessions_.erase(std::remove_if(sessions_.begin(), sessions_.end(), + [&session](const std::vector& e) { + return std::equal(e.begin(), e.end(), session.begin()); + }), + sessions_.end()); } } // namespace castkeydrm \ No newline at end of file