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

Commit aa81dd75 authored by Phil Burk's avatar Phil Burk
Browse files

aaudio: prevent out-of-bounds read in resampler

The cursor was initialized to -1 instead of 0.
Now it is set to 0.
This fixes a crash when running with HWASAN.

The mInputCallCount is now initialized to kInitialCounter.
See https://github.com/google/oboe/issues/987
for more info and a regression test.

Bug: 336391852
Test: Flash a HWASAN build then
Test: atest CtsNativeMediaAAudioTestCases
Test: or see bug for steps using OboeTester
Flag: EXEMPT bugfix
Change-Id: Ifadaa94a755c77e4888d66009a8de7df4bce22bc
parent 86186887
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -28,7 +28,8 @@ SampleRateConverter::SampleRateConverter(int32_t channelCount,

void SampleRateConverter::reset() {
    FlowGraphNode::reset();
    mInputCursor = kInitialCallCount;
    mInputCallCount = kInitialCallCount;
    mInputCursor = 0;
}

// Return true if there is a sample available.
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ private:
    int32_t mNumValidInputFrames = 0; // number of valid frames currently in the input port buffer
    // We need our own callCount for upstream calls because calls occur at a different rate.
    // This means we cannot have cyclic graphs or merges that contain an SRC.
    int64_t mInputCallCount = 0;
    int64_t mInputCallCount = kInitialCallCount;

};