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

Commit 612d8fcb authored by Ivan Lozano's avatar Ivan Lozano
Browse files

Fix overflow sanitizer in Visualizer_command.

There's an intended integer overflow in the Visualizer_command function.
This refactors it to use the builtin overflow-safe function.

 runtime error: unsigned integer overflow: 1664 - 4048 cannot be
 represented in type 'unsigned int'

Bug: 30969751
Test: Builds and boots.
Change-Id: I63a505f4b073480f52d0b073ec5e45c52212caa8
parent dc68185a
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -594,7 +594,9 @@ int Visualizer_command(effect_handle_t self, uint32_t cmdCode, uint32_t cmdSize,
                    deltaSmpl = CAPTURE_BUF_SIZE;
                }

                int32_t capturePoint = (int32_t)pContext->mCaptureIdx - deltaSmpl;
                int32_t capturePoint;
                //capturePoint = (int32_t)pContext->mCaptureIdx - deltaSmpl;
                __builtin_sub_overflow((int32_t)pContext->mCaptureIdx, deltaSmpl, &capturePoint);
                // a negative capturePoint means we wrap the buffer.
                if (capturePoint < 0) {
                    uint32_t size = -capturePoint;