Skip to content

Commit 130464f

Browse files
committed
audio: copier: Fix memory corruption with TRANS_GAIN with gcc
The dst pointer must not be used directly while applying TRANS_GAIN to avoid corrupting memory in heap. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Fixes: 6993617 ("copier: gain: add processing functions") Closes: #10318
1 parent a86f371 commit 130464f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/audio/copier/copier_generic.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ int copier_gain_input16(struct comp_buffer *buff, enum copier_gain_state state,
169169

170170
/* Apply fade */
171171
for (j = 0; j < nch; j++) {
172-
dst += j;
172+
dst_tmp = dst + j;
173173
/* Quadratic fade part in Q15 format*/
174174
gain_env_sq = q_multsr_16x16(gain_env[j], gain_env[j], 15);
175175

@@ -180,8 +180,8 @@ int copier_gain_input16(struct comp_buffer *buff, enum copier_gain_state state,
180180
gain_env_sq, 15);
181181

182182
for (i = 0; i < nmax; i += nch)
183-
dst[i] = q_multsr_sat_16x16(dst[i], gain,
184-
GAIN_Q10_INT_SHIFT);
183+
dst_tmp[i] = q_multsr_sat_16x16(dst_tmp[i], gain,
184+
GAIN_Q10_INT_SHIFT);
185185
}
186186
samples -= nmax;
187187
dst = audio_stream_wrap(&buff->stream, dst + nmax);
@@ -260,7 +260,7 @@ int copier_gain_input32(struct comp_buffer *buff, enum copier_gain_state state,
260260

261261
/* Apply fade */
262262
for (j = 0; j < nch; j++) {
263-
dst += j;
263+
dst_tmp = dst + j;
264264
/* Quadratic fade part in Q15 format*/
265265
gain_env_sq = q_multsr_16x16(gain_env[j], gain_env[j], 15);
266266

@@ -271,8 +271,8 @@ int copier_gain_input32(struct comp_buffer *buff, enum copier_gain_state state,
271271
gain_env_sq, 15);
272272

273273
for (i = 0; i < nmax; i += nch)
274-
dst[i] = q_multsr_sat_32x32(dst[i], gain,
275-
GAIN_Q10_INT_SHIFT);
274+
dst_tmp[i] = q_multsr_sat_32x32(dst_tmp[i], gain,
275+
GAIN_Q10_INT_SHIFT);
276276
}
277277
samples -= nmax;
278278
dst = audio_stream_wrap(&buff->stream, dst + nmax);

0 commit comments

Comments
 (0)