mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 23:05:04 +01:00
Hotfix crashes for [extreme] time-stretch -- #7305
e.g. stretch-shrink 3712 samples down to 1780. The filter order defines nFact which can become larger than length - 2 leading to out-of-bounds array access. e.g. m_ord = 2 -> nFilt = 2, nFact = 6; process < 7 samples (here 6)
This commit is contained in:
parent
2513aad1ed
commit
c0c24aff72
1 changed files with 15 additions and 1 deletions
|
|
@ -13,6 +13,7 @@
|
||||||
COPYING included with this distribution for more information.
|
COPYING included with this distribution for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include "FiltFilt.h"
|
#include "FiltFilt.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
@ -55,6 +56,14 @@ void FiltFilt::process(double *src, double *dst, unsigned int length)
|
||||||
|
|
||||||
if (length == 0) return;
|
if (length == 0) return;
|
||||||
|
|
||||||
|
if (length < 2) {
|
||||||
|
fprintf (stderr, "FiltFilt::process called for %d samples\n", length);
|
||||||
|
for( i = 0; i < length; i++ ) {
|
||||||
|
dst[i] = src [i];
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int nFilt = m_ord + 1;
|
unsigned int nFilt = m_ord + 1;
|
||||||
unsigned int nFact = 3 * ( nFilt - 1);
|
unsigned int nFact = 3 * ( nFilt - 1);
|
||||||
unsigned int nExt = length + 2 * nFact;
|
unsigned int nExt = length + 2 * nFact;
|
||||||
|
|
@ -79,11 +88,16 @@ void FiltFilt::process(double *src, double *dst, unsigned int length)
|
||||||
m_filtScratchIn[ index++ ] = sample0 - src[ i ];
|
m_filtScratchIn[ index++ ] = sample0 - src[ i ];
|
||||||
}
|
}
|
||||||
index = 0;
|
index = 0;
|
||||||
for( i = 0; i < nFact; i++ )
|
for( i = 0; i < nFact && i + 2 < length; i++ )
|
||||||
{
|
{
|
||||||
m_filtScratchIn[ (nExt - nFact) + index++ ] = sampleN - src[ (length - 2) - i ];
|
m_filtScratchIn[ (nExt - nFact) + index++ ] = sampleN - src[ (length - 2) - i ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(; i < nFact; i++ )
|
||||||
|
{
|
||||||
|
m_filtScratchIn[ (nExt - nFact) + index++ ] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
index = 0;
|
index = 0;
|
||||||
for( i = 0; i < length; i++ )
|
for( i = 0; i < length; i++ )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue