From 14761c80a93408ba864c2e440404ef6b303a0104 Mon Sep 17 00:00:00 2001 From: Gloria Wang Date: Fri, 25 Feb 2011 09:47:52 -0800 Subject: [PATCH] Fix for bug 3477330 This patch fixs a crash bug caused by using a NULL DecryptHandle pointer in the DRM Framework. Fix by using sp instead. Change-Id: I1355d4719857ab64ad6cd12803fcf19e45bb50a0 --- proprietary/wvm/WVMExtractorImpl.cpp | 12 ++++++++++-- proprietary/wvm/WVMMediaSource.cpp | 5 ++++- proprietary/wvm/include/WVMExtractorImpl.h | 2 ++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/proprietary/wvm/WVMExtractorImpl.cpp b/proprietary/wvm/WVMExtractorImpl.cpp index c97d8600..81060336 100644 --- a/proprietary/wvm/WVMExtractorImpl.cpp +++ b/proprietary/wvm/WVMExtractorImpl.cpp @@ -32,7 +32,7 @@ using namespace android; -static DecryptHandle *sDecryptHandle; +static sp sDecryptHandle; static DrmManagerClient *sDrmManagerClient; @@ -86,7 +86,7 @@ WVMExtractorImpl::WVMExtractorImpl(sp dataSource) mSession(NULL), mSetupStatus(OK) { - dataSource->getDrmInfo(&sDecryptHandle, &sDrmManagerClient); + dataSource->getDrmInfo(sDecryptHandle, &sDrmManagerClient); // Set up callouts AndroidSetLogCallout(android_printbuf); @@ -134,6 +134,14 @@ WVMExtractorImpl::WVMExtractorImpl(sp dataSource) WVMExtractorImpl::~WVMExtractorImpl() { } +// Release decrypt handle when media sources are destroyed +void WVMExtractorImpl::cleanup() +{ + if (sDecryptHandle.get()) { + sDecryptHandle.clear(); + } +} + // // Configure metadata for video and audio sources // diff --git a/proprietary/wvm/WVMMediaSource.cpp b/proprietary/wvm/WVMMediaSource.cpp index b775cbd2..6f69c9ed 100644 --- a/proprietary/wvm/WVMMediaSource.cpp +++ b/proprietary/wvm/WVMMediaSource.cpp @@ -19,6 +19,7 @@ #include "WVMMediaSource.h" #include "WVMFileSource.h" +#include "WVMExtractorImpl.h" #include "media/stagefright/MediaErrors.h" #include "media/stagefright/MediaDefs.h" #include "media/stagefright/MediaDebug.h" @@ -274,8 +275,10 @@ WVMMediaSource::~WVMMediaSource() } if (mESSelector == WV_EsSelector_Video) { - if (mSession != NULL) + if (mSession != NULL) { WV_Teardown(mSession); + } + WVMExtractorImpl::cleanup(); } } diff --git a/proprietary/wvm/include/WVMExtractorImpl.h b/proprietary/wvm/include/WVMExtractorImpl.h index ba04c1d1..03d46b62 100644 --- a/proprietary/wvm/include/WVMExtractorImpl.h +++ b/proprietary/wvm/include/WVMExtractorImpl.h @@ -45,6 +45,8 @@ public: virtual sp getMetaData(); + static void cleanup(); + protected: virtual ~WVMExtractorImpl();