Hi,

I found a problem with the pitch_shift plugin. It works fine if one sets
up all parameters and let it run. But when you change it's parameters
while it is running and there are large and fast changes, there will be
a buffer overflow with segfault and crash.

I attached a patch to fix that.

My question now is: do you plan to release a new version of aRts in the
next weeks? Otherwise I would need to include a copy of that plugin in
my next Kwave release and write some support code to be able to use it.

Thomas
--
________________________________________________________________________
Thomas Eschenbacher <[EMAIL PROTECTED]> [LANG=de_DE | en_EN]
--- arts/modules/synth_pitch_shift_impl.cc.orig 2002-04-22 20:47:08.000000000 +0200
+++ arts/modules/synth_pitch_shift_impl.cc      2003-06-05 22:45:32.000000000 +0200
@@ -145,28 +146,18 @@
                         * Interpolate value from buffer position 1
                         */
                        error = modf(b1pos, &int_pos);
-       
-                       position = dbpos - (int)int_pos;
-                       if (position < 0)
-                               position += MAXDELAY;
-                       position1 = position - 1;
-                       if (position1 < 0)
-                               position1 += MAXDELAY;
 
+                       position = (dbpos + MAXDELAY - ((int)int_pos % MAXDELAY)) % 
MAXDELAY;
+                       position1 = ((MAXDELAY-1) + position) % MAXDELAY;
                        b1value = dbuffer[position] * (1 - error) + dbuffer[position1] 
* error;
 
                        /*
                         * Interpolate value from buffer position 2
                         */
                        error = modf(b2pos,&int_pos);
-       
-                       position = dbpos - (int)int_pos;
-                       if (position < 0)
-                               position += MAXDELAY;
-                       position1 = position-1;
-                       if ( position1 < 0)
-                               position1 += MAXDELAY;
 
+                       position = (dbpos + MAXDELAY - ((int)int_pos % MAXDELAY)) % 
MAXDELAY;
+                       position1 = ((MAXDELAY-1) + position) % MAXDELAY;
                        b2value = dbuffer[position]*(1-error) + 
dbuffer[position1]*error;
 
                        /*

Reply via email to