bytedance / mockey

a simple and easy-to-use golang mock library
Apache License 2.0
556 stars 22 forks source link

fix: check variadic function's cap before calling #30

Closed Sychorius closed 11 months ago

Sychorius commented 11 months ago

Change-Id: Ic9ac689e33484828b27adeca2d342e87c4230362

What type of PR is this?

fix

What this PR does / why we need it (en: English/zh: Chinese):

en: There are a few cases that lastArgs.cap == 0 but lastArg.len == MAX_INT when calling variadic functions (arm64). Currently we have no idea how it happens. In that case we assume that lastArgs.len should less than lastArg.cap zh: 在一些极少情况下mock可变长参数的函数,调用时最后的变长参数slice的len会变得很大,但是cap为0。目前还不清楚为什么slice的len被踩坏了,这里先做一个校验,如果len>cap的话按照cap长度调用mock函数

Which issue(s) this PR fixes: