From d08f25abd3b1c5659df530b0ec557ac01537b8aa Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Sun, 29 May 2016 12:57:57 -1000 Subject: [PATCH] Out-of-bounds memory access fixes --- lib/audiodev/AudioMatrixSSE.cpp | 6 ++---- soxr/src/soxr.c | 9 +++++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/audiodev/AudioMatrixSSE.cpp b/lib/audiodev/AudioMatrixSSE.cpp index bd94481..9cef6d9 100644 --- a/lib/audiodev/AudioMatrixSSE.cpp +++ b/lib/audiodev/AudioMatrixSSE.cpp @@ -108,8 +108,7 @@ int32_t* AudioMatrixMono::mixMonoSampleData(const AudioVoiceEngineMixInfo& info, _mm_set_ps(t, t, t2, t2)), _mm_mul_ps(_mm_shuffle_ps(m_oldCoefs.q[0], m_oldCoefs.q[0], _MM_SHUFFLE(1, 0, 1, 0)), _mm_set_ps(omt, omt, omt2, omt2))); - samps.q = _mm_cvtepi32_ps(_mm_loadu_si128(reinterpret_cast(dataIn))); - samps.q = _mm_shuffle_ps(samps.q, samps.q, _MM_SHUFFLE(1, 0, 1, 0)); + samps.q = _mm_cvtepi32_ps(_mm_set_epi32(dataIn[1], dataIn[0], dataIn[1], dataIn[0])); __m128i* out = reinterpret_cast<__m128i*>(dataOut); __m128 pre = _mm_add_ps(_mm_cvtepi32_ps(_mm_loadu_si128(out)), _mm_mul_ps(coefs.q, samps.q)); @@ -208,8 +207,7 @@ int32_t* AudioMatrixMono::mixMonoSampleData(const AudioVoiceEngineMixInfo& info, { TVectorUnion coefs, samps; coefs.q = _mm_shuffle_ps(m_coefs.q[0], m_coefs.q[0], _MM_SHUFFLE(1, 0, 1, 0)); - samps.q = _mm_cvtepi32_ps(_mm_loadu_si128(reinterpret_cast(dataIn))); - samps.q = _mm_shuffle_ps(samps.q, samps.q, _MM_SHUFFLE(1, 0, 1, 0)); + samps.q = _mm_cvtepi32_ps(_mm_set_epi32(dataIn[1], dataIn[0], dataIn[1], dataIn[0])); __m128i* out = reinterpret_cast<__m128i*>(dataOut); __m128i huh2 = _mm_loadu_si128(reinterpret_cast(out)); diff --git a/soxr/src/soxr.c b/soxr/src/soxr.c index dc61ad9..852b7ce 100644 --- a/soxr/src/soxr.c +++ b/soxr/src/soxr.c @@ -481,8 +481,13 @@ static size_t soxr_output_no_callback(soxr_t p, soxr_buf_t out, size_t len) done = done1; } else #endif - for (u = 0; u < p->num_channels; ++u) - done = soxr_output_1ch(p, u, ((soxr_bufs_t)out)[u], len, separated); + { + if (p->num_channels > 1) { + for (u = 0; u < p->num_channels; ++u) + done = soxr_output_1ch(p, u, ((soxr_bufs_t)out)[u], len, separated); + } else + done = soxr_output_1ch(p, 0, out, len, separated); + } if (!separated) p->clips += (p->interleave)(p->io_spec.otype, &out, (sample_t const * const *)p->channel_ptrs,