Fixed buffer overflows in resamplers.

I'm not confident this is a complete fix, but I'm not confident the current
 resamplers are really worth keeping at all, either.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404352
This commit is contained in:
Ryan C. Gordon 2009-12-28 08:28:24 +00:00
parent 1411a41ebd
commit 4d3b6eafc8
2 changed files with 205 additions and 201 deletions

File diff suppressed because it is too large Load Diff

View File

@ -537,15 +537,19 @@ ${sym}(SDL_AudioCVT * cvt, SDL_AudioFormat format)
const int dstsize = cvt->len_cvt $lencvtop $multiple;
EOF
my $endcomparison = '!=';
# Upsampling (growing the buffer) needs to work backwards, since we
# overwrite the buffer as we go.
if ($upsample) {
$endcomparison = '>'; # dst > target
print <<EOF;
$fctype *dst = (($fctype *) (cvt->buf + dstsize)) - $channels;
const $fctype *src = (($fctype *) (cvt->buf + cvt->len_cvt)) - $channels;
const $fctype *target = ((const $fctype *) cvt->buf) - $channels;
EOF
} else {
$endcomparison = '<'; # dst < target
print <<EOF;
$fctype *dst = ($fctype *) cvt->buf;
const $fctype *src = ($fctype *) cvt->buf;
@ -562,7 +566,7 @@ EOF
}
print <<EOF;
while (dst != target) {
while (dst $endcomparison target) {
EOF
for (my $i = 0; $i < $channels; $i++) {