From 4d917e3ee80a451ce069123d4195eadd5f5fe058 Mon Sep 17 00:00:00 2001 From: Rahul Frias Date: Sun, 12 May 2019 02:15:12 -0700 Subject: [PATCH] Ref count Timer implementation [ Merge of http://go/wvgerrit/78763 ] The android timer instance is held by a regular pointer rather than reference counted as all classes that derive from RefBase should be. This could result in a double deallocation, if the timer is ever passed to a strong pointer. Bug: 79364026 Test: WV unit/integration tests. GtsMediaTestCases. Play movies playback tests. Change-Id: I01f622bc045e1012f2240b3775a6d121f9415463 --- libwvdrmengine/cdm/include/timer.h | 4 +++- libwvdrmengine/cdm/src/timer.cpp | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libwvdrmengine/cdm/include/timer.h b/libwvdrmengine/cdm/include/timer.h index a6a4138f..a9643a72 100644 --- a/libwvdrmengine/cdm/include/timer.h +++ b/libwvdrmengine/cdm/include/timer.h @@ -9,6 +9,8 @@ #include +#include "utils/StrongPointer.h" + #include "disallow_copy_and_assign.h" namespace wvcdm { @@ -45,7 +47,7 @@ class Timer { bool IsRunning(); private: - Impl *impl_; + android::sp impl_; CORE_DISALLOW_COPY_AND_ASSIGN(Timer); }; diff --git a/libwvdrmengine/cdm/src/timer.cpp b/libwvdrmengine/cdm/src/timer.cpp index 13c4ebd9..a0e0b135 100644 --- a/libwvdrmengine/cdm/src/timer.cpp +++ b/libwvdrmengine/cdm/src/timer.cpp @@ -81,9 +81,6 @@ Timer::Timer() : impl_(new Timer::Impl()) { Timer::~Timer() { if (IsRunning()) Stop(); - - delete impl_; - impl_ = NULL; } bool Timer::Start(TimerHandler *handler, uint32_t time_in_secs) {