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

Commit cd4c7240 authored by wendy lin's avatar wendy lin Committed by Andy Hung
Browse files

fix audioflinger integer multiplication overflow

when underrun duration is over 3 sec, overflow happens
for multiplication of nsec=sec*1000000000. Use correct format transform
to solve it.

Bug: 135075416
Test: run MTBF test

Change-Id: I0a09ca41f2fad055ce0cfa18f936131b7a630f52
parent 39ec5a7a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -305,7 +305,7 @@ bool FastThread::threadLoop()
                    // compute the delta value of clock_gettime(CLOCK_MONOTONIC)
                    uint32_t monotonicNs = nsec;
                    if (sec > 0 && sec < 4) {
                        monotonicNs += sec * 1000000000;
                        monotonicNs += sec * 1000000000U; // unsigned to prevent signed overflow.
                    }
                    // compute raw CPU load = delta value of clock_gettime(CLOCK_THREAD_CPUTIME_ID)
                    uint32_t loadNs = 0;
@@ -321,7 +321,7 @@ bool FastThread::threadLoop()
                            }
                            loadNs = nsec;
                            if (sec > 0 && sec < 4) {
                                loadNs += sec * 1000000000;
                                loadNs += sec * 1000000000U; // unsigned to prevent signed overflow.
                            }
                        } else {
                            // first time through the loop