From 25a6185c8434c62af73d2c6c91bda5fc50d20ca7 Mon Sep 17 00:00:00 2001 From: Rahul Frias Date: Tue, 25 Aug 2015 10:40:12 -0700 Subject: [PATCH] Address releaseAllSecureStops crash [ Merge of http://go/wvgerrit/15474 ] Changes to releaseAllSecureStops made use of a session that was initialized only if getSecureStops had been previously called. If it was not, accessing the session resulted in a segfault. This was uncovered by a change in how the Netflix app invoked mediaDrm. b/23498809 Change-Id: Ib426ae1830c3a42c5e0849f1b6e8bbfe0d2c74ff --- libwvdrmengine/cdm/core/src/cdm_engine.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libwvdrmengine/cdm/core/src/cdm_engine.cpp b/libwvdrmengine/cdm/core/src/cdm_engine.cpp index f0e50681..2b6072ce 100644 --- a/libwvdrmengine/cdm/core/src/cdm_engine.cpp +++ b/libwvdrmengine/cdm/core/src/cdm_engine.cpp @@ -804,6 +804,11 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id, } CdmResponseType CdmEngine::ReleaseAllUsageInfo(const std::string& app_id) { + if (NULL == usage_property_set_.get()) { + usage_property_set_.reset(new UsagePropertySet()); + } + usage_property_set_->set_app_id(app_id); + CdmResponseType status = NO_ERROR; for (int j = kSecurityLevelL1; j < kSecurityLevelUnknown; ++j) { DeviceFiles handle; @@ -814,6 +819,13 @@ CdmResponseType CdmEngine::ReleaseAllUsageInfo(const std::string& app_id) { "stops", j); status = RELEASE_ALL_USAGE_INFO_ERROR_1; } else { + SecurityLevel security_level = + static_cast(j) == kSecurityLevelL3 + ? kLevel3 + : kLevelDefault; + usage_property_set_->set_security_level(security_level); + usage_session_.reset( + new CdmSession(usage_property_set_.get(), EMPTY_ORIGIN, NULL)); CdmResponseType status2 = usage_session_-> DeleteMultipleUsageInformation(provider_session_tokens); if (status2 != NO_ERROR) { @@ -826,6 +838,7 @@ CdmResponseType CdmEngine::ReleaseAllUsageInfo(const std::string& app_id) { status = RELEASE_ALL_USAGE_INFO_ERROR_2; } } + usage_session_.reset(NULL); return status; }