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

Commit d09eaeaa authored by Nick Desaulniers's avatar Nick Desaulniers
Browse files

[media][sfplugin] fix -Wdangling-gsl



C2BufferData#linearBlocks() returns a std::vector. Chaining method calls
results in an immediate dereference of a dangling pointer. Save a
reference to the otherwise temporary for the duration of the function
call.

Bug: 139945549
Test: mm
Change-Id: I99d662a8fe5deec652cdcd82f420c836c76d5539
Signed-off-by: default avatarNick Desaulniers <ndesaulniers@google.com>
parent 9ee56ec1
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -878,9 +878,10 @@ void OutputBuffersArray::realloc(const std::shared_ptr<C2Buffer> &c2buffer) {
    switch (c2buffer->data().type()) {
        case C2BufferData::LINEAR: {
            uint32_t size = kLinearBufferSize;
            const C2ConstLinearBlock &block = c2buffer->data().linearBlocks().front();
            if (block.size() < kMaxLinearBufferSize / 2) {
                size = block.size() * 2;
            const std::vector<C2ConstLinearBlock> &linear_blocks = c2buffer->data().linearBlocks();
            const uint32_t block_size = linear_blocks.front().size();
            if (block_size < kMaxLinearBufferSize / 2) {
                size = block_size * 2;
            } else {
                size = kMaxLinearBufferSize;
            }