ermig1979 / Simd

C++ image processing and machine learning library with using of SIMD: SSE, AVX, AVX-512, AMX for x86/x64, VMX(Altivec) and VSX(Power7) for PowerPC, NEON for ARM.
http://ermig1979.github.io/Simd
MIT License
2.04k stars 407 forks source link

Out of range access in Simd::Base::Detect32f #92

Closed ilue closed 5 years ago

ilue commented 5 years ago

Simd::Avx2::Detect32f` may call Simd::Base::Detect32f with out-of-range startStage.

https://github.com/ermig1979/Simd/blob/0b2929bcf7b87960b0a03a57ca7236b3b1076e3a/src/Simd/SimdAvx2Detection.cpp#L175 when i is hid.stages.size() - 1

https://github.com/ermig1979/Simd/blob/0b2929bcf7b87960b0a03a57ca7236b3b1076e3a/src/Simd/SimdAvx2Detection.cpp#L216 i + 1 will be hid.stages.size()

https://github.com/ermig1979/Simd/blob/0b2929bcf7b87960b0a03a57ca7236b3b1076e3a/src/Simd/SimdBaseDetection.cpp#L715 so access to stages[startStage] is out-of-range

Similar problem exists in SimdSse41Detection.cpp and SimdNeonDetection.cpp.

ermig1979 commented 5 years ago

Thank you for bug report. I have fixed the bug.