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

Commit d8529a4c authored by George Burgess IV's avatar George Burgess IV
Browse files

mediacodec: hoist NULL assignments to variable initialization

There're paths through this function where we end up using `key` (and
presumably `iv`) without setting them. These paths _might_ be
dynamically unreachable (I'm unfamiliar with this codebase), but it's
locally unclear that that's the case.

As a security mitigation, our compiler will zero-initialize these
in all cases anyway. That said, it's probably best to make it more
obvious to the reader that these are intended to be NULL on all paths
except the `else if (!c2Buffer)` one

Bug: None
Test: TreeHugger
Change-Id: Ib3c8e7d6b7cc8b794118c8784419458191d0cb56
parent ff9564c7
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -4506,8 +4506,8 @@ status_t MediaCodec::onQueueInputBuffer(const sp<AMessage> &msg) {
    }
    const CryptoPlugin::SubSample *subSamples;
    size_t numSubSamples;
    const uint8_t *key;
    const uint8_t *iv;
    const uint8_t *key = NULL;
    const uint8_t *iv = NULL;
    CryptoPlugin::Mode mode = CryptoPlugin::kMode_Unencrypted;

    // We allow the simpler queueInputBuffer API to be used even in
@@ -4522,8 +4522,6 @@ status_t MediaCodec::onQueueInputBuffer(const sp<AMessage> &msg) {

            subSamples = &ss;
            numSubSamples = 1;
            key = NULL;
            iv = NULL;
            pattern.mEncryptBlocks = 0;
            pattern.mSkipBlocks = 0;
        }