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

Commit 6f5a43f4 authored by Chad Brubaker's avatar Chad Brubaker
Browse files

Fix benign overflow in ToneGenerator.cpp

while (count--) causes an unsigned overflow when count = 0, refactor the
condition to avoid this.

Change-Id: I91a8c93e6be715d80070a4c94c1de712cb659265
parent 1f8749f2
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1581,7 +1581,8 @@ void ToneGenerator::WaveGenerator::getSamples(short *outBuffer,
        }
        long dec = lAmplitude/count;
        // loop generation
        while (count--) {
        while (count) {
            count--;
            Sample = ((lA1 * lS1) >> S_Q14) - lS2;
            // shift delay
            lS2 = lS1;
@@ -1592,7 +1593,8 @@ void ToneGenerator::WaveGenerator::getSamples(short *outBuffer,
        }
    } else {
        // loop generation
        while (count--) {
        while (count) {
            count--;
            Sample = ((lA1 * lS1) >> S_Q14) - lS2;
            // shift delay
            lS2 = lS1;