A2DP: Fix integer sanitizer in SBC encoder
There were three potential integer overflow within SBC software encoder: * embdrv/sbc/encoder/srce/sbc_packing.c:144:38: runtime error: unsigned integer overflow: 4294967231 + 8192 cannot be represented in type 'unsigned int' * embdrv/sbc/encoder/srce/sbc_packing.c:147:9: runtime error: signed integer overflow: 37932 * 65535 cannot be represented in type 'int' * embdrv/sbc/encoder/srce/sbc_packing.c:147:9: runtime error: signed integer overflow: 178177545 + 2146959360 cannot be represented in type 'int' They were caught by the integer sanitizer, and 1. (*ps32SbPtr >> 2) is either greater than 0xFF00,0000 or less than 0x007F,FFFF, so just cast to a signed integer explicitly. 2. Positive integer between 0x8000,0000 ~ 0xFFFF,FFFF can't be represented in type 'int', but is still feasible in 32-bits. 3. s32OutLow is the lower byte of a 64 bits integer, but can't have the carry values which is only for the higher byte. This change gives the compiler a signed 64-bits variable, and trusts it to do better optimization at multiplication. Bug: 153402404 Test: make sure there are no integer sanitization errors. Change-Id: I5046a42f9927c1aa7c25da2828c4f921ba7a5021 Merged-In: I5046a42f9927c1aa7c25da2828c4f921ba7a5021 (cherry picked from commit a42db783434da238e4daade95ce2adb1bca0f138)
Loading
Please register or sign in to comment