Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7676a406 authored by Peter Kalauskas's avatar Peter Kalauskas
Browse files

Make assignment of mPlugin members consistent

Before, it was possible for mPlugin, mPluginV1_1, and mPluginV1_2 to be
assigned to different plugins. Now, they are guaranteed to always point
to the same object. Also to be safe, mPlugin is set to NULL if there is
an initailization error.

Test: Run gts on blueline
Bug: 112386116
Bug: 121382196
Change-Id: Ie3ff7369e0c66d4502fab3f4a1d18b2882140143
parent f25675d3
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -553,12 +553,14 @@ status_t DrmHal::createPlugin(const uint8_t uuid[16],
        const String8& appPackageName) {
    Mutex::Autolock autoLock(mLock);

    for (size_t i = 0; i < mFactories.size(); i++) {
    for (size_t i = mFactories.size() - 1; i >= 0; i--) {
        if (mFactories[i]->isCryptoSchemeSupported(uuid)) {
            mPlugin = makeDrmPlugin(mFactories[i], uuid, appPackageName);
            if (mPlugin != NULL) {
            auto plugin = makeDrmPlugin(mFactories[i], uuid, appPackageName);
            if (plugin != NULL) {
                mPlugin = plugin;
                mPluginV1_1 = drm::V1_1::IDrmPlugin::castFrom(mPlugin);
                mPluginV1_2 = drm::V1_2::IDrmPlugin::castFrom(mPlugin);
                break;
            }
        }
    }
@@ -567,6 +569,9 @@ status_t DrmHal::createPlugin(const uint8_t uuid[16],
        mInitCheck = ERROR_UNSUPPORTED;
    } else {
        if (!mPlugin->setListener(this).isOk()) {
            mPlugin = NULL;
            mPluginV1_1 = NULL;
            mPluginV1_2 = NULL;
            mInitCheck = DEAD_OBJECT;
        } else {
            mInitCheck = OK;