Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed bug 3488 - Random crashes (because Memory overlap in audio conv…
…erters detected by Valgrind)

Vitaly Novichkov

Okay, when I researched code and algorithm, I tried to replace condition "while(dst >= target)" with "while(dst > target)" and crashes are gone.
Seems on some moments it tries to write into the place before memory block begin, therefore phantom crashes appearing after some moments.
  • Loading branch information
slouken committed Nov 13, 2016
1 parent 3769615 commit c13a077
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/audio/SDL_audiotypecvt.c
Expand Up @@ -239,7 +239,7 @@ SDL_Upsample_Arbitrary(SDL_AudioCVT *cvt, const int channels)
SDL_memcpy(sample, src, cpy);
SDL_memcpy(last_sample, src, cpy);

while (dst >= target) {
while (dst > target) {
SDL_memcpy(dst, sample, cpy);
dst -= 8;
eps += srcsize;
Expand Down Expand Up @@ -320,7 +320,7 @@ SDL_Upsample_x2(SDL_AudioCVT *cvt, const int channels)
SDL_assert(channels <= 8);
SDL_memcpy(last_sample, src, cpy);

while (dst >= target) {
while (dst > target) {
for (i = 0; i < channels; i++) {
dst[i] = (float) ((((double)src[i]) + ((double)last_sample[i])) * 0.5);
}
Expand Down Expand Up @@ -355,7 +355,7 @@ SDL_Upsample_x4(SDL_AudioCVT *cvt, const int channels)
SDL_assert(channels <= 8);
SDL_memcpy(last_sample, src, cpy);

while (dst >= target) {
while (dst > target) {
for (i = 0; i < channels; i++) {
dst[i] = (float) ((((double) src[i]) + (3.0 * ((double) last_sample[i]))) * 0.25);
}
Expand Down

0 comments on commit c13a077

Please sign in to comment.