engine: client: s_mix: attempt to fix S_InterpolateCubic2x buffer overflow
This commit is contained in:
parent
8a8cdd2927
commit
d1a571201b
1 changed files with 5 additions and 6 deletions
|
@ -696,7 +696,8 @@ static void S_Interpolate2xCubic( portable_samplepair_t *pbuffer, portable_sampl
|
||||||
// c = (x1 - xm1) / 2;
|
// c = (x1 - xm1) / 2;
|
||||||
// y [outpos] = (((a * finpos) + b) * finpos + c) * finpos + x0;
|
// y [outpos] = (((a * finpos) + b) * finpos + c) * finpos + x0;
|
||||||
|
|
||||||
int i, upCount = count << 1;
|
int i;
|
||||||
|
const int upCount = Q_min( count << 1, PAINTBUFFER_SIZE );
|
||||||
int a, b, c;
|
int a, b, c;
|
||||||
int xm1, x0, x1, x2;
|
int xm1, x0, x1, x2;
|
||||||
portable_samplepair_t *psamp0;
|
portable_samplepair_t *psamp0;
|
||||||
|
@ -705,8 +706,6 @@ static void S_Interpolate2xCubic( portable_samplepair_t *pbuffer, portable_sampl
|
||||||
portable_samplepair_t *psamp3;
|
portable_samplepair_t *psamp3;
|
||||||
int outpos = 0;
|
int outpos = 0;
|
||||||
|
|
||||||
Assert( upCount <= PAINTBUFFER_SIZE );
|
|
||||||
|
|
||||||
// pfiltermem holds 6 samples from previous buffer pass
|
// pfiltermem holds 6 samples from previous buffer pass
|
||||||
// process 'count' samples
|
// process 'count' samples
|
||||||
for( i = 0; i < count; i++)
|
for( i = 0; i < count; i++)
|
||||||
|
@ -748,7 +747,8 @@ static void S_Interpolate2xCubic( portable_samplepair_t *pbuffer, portable_sampl
|
||||||
// write out interpolated sample, increment output counter
|
// write out interpolated sample, increment output counter
|
||||||
temppaintbuffer[outpos++].right = a/8 + b/4 + c/2 + x0;
|
temppaintbuffer[outpos++].right = a/8 + b/4 + c/2 + x0;
|
||||||
|
|
||||||
Assert( outpos <= ( sizeof( temppaintbuffer ) / sizeof( temppaintbuffer[0] )));
|
if( outpos > ARRAYSIZE( temppaintbuffer ))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert( cfltmem >= 3 );
|
Assert( cfltmem >= 3 );
|
||||||
|
@ -759,8 +759,7 @@ static void S_Interpolate2xCubic( portable_samplepair_t *pbuffer, portable_sampl
|
||||||
pfiltermem[2] = pbuffer[upCount - 1];
|
pfiltermem[2] = pbuffer[upCount - 1];
|
||||||
|
|
||||||
// copy temppaintbuffer back into paintbuffer
|
// copy temppaintbuffer back into paintbuffer
|
||||||
for( i = 0; i < upCount; i++ )
|
memcpy( pbuffer, temppaintbuffer, sizeof( *pbuffer ) * upCount );
|
||||||
pbuffer[i] = temppaintbuffer[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// pass forward over passed in buffer and linearly interpolate all odd samples
|
// pass forward over passed in buffer and linearly interpolate all odd samples
|
||||||
|
|
Loading…
Add table
Reference in a new issue