Changeset 287


Ignore:
Timestamp:
Mar 5, 2006 1:33:57 PM (19 years ago)
Author:
bennylp
Message:

Fixed bug where resample may write pass the output buffer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/resample.c

    r277 r287  
    3939 *  - move stddefs.h and resample.h to this file. 
    4040 *  - const correctness. 
     41 *  - fixed SrcLinear() may write pass output buffer. 
     42 *  - assume the same for SrcUp() and SrcUD(), so put the same 
     43 *    protection. 
    4144 */ 
    4245#include <pjmedia/resample.h> 
     
    204207    UWORD time = 0; 
    205208    const HWORD *xp; 
    206     HWORD *Ystart; 
     209    HWORD *Ystart, *Yend; 
    207210    WORD v,x1,x2; 
    208211     
     
    215218     
    216219    Ystart = Y; 
     220    Yend = Ystart + (unsigned)(nx * pFactor); 
    217221    endTime = time + (1<<Np)*(WORD)nx; 
    218     while (time < endTime) 
     222    while (time < endTime && Y < Yend)  /* bennylp fix: added Y < Yend */ 
    219223    { 
    220224        iconst = (time) & Pmask; 
     
    341345{ 
    342346    const HWORD *xp; 
    343     HWORD *Ystart; 
     347    HWORD *Ystart, *Yend; 
    344348    WORD v; 
    345349     
     
    353357     
    354358    Ystart = Y; 
     359    Yend = Ystart + (unsigned)(nx * pFactor); 
    355360    endTime = time + (1<<Np)*(WORD)nx; 
    356     while (time < endTime) 
     361    while (time < endTime && Y < Yend)  /* bennylp fix: protect Y */ 
    357362    { 
    358363        xp = &X[time>>Np];      /* Ptr to current input sample */ 
     
    380385{ 
    381386    const HWORD *xp; 
    382     HWORD *Ystart; 
     387    HWORD *Ystart, *Yend; 
    383388    WORD v; 
    384389     
     
    396401     
    397402    Ystart = Y; 
     403    Yend = Ystart + (unsigned)(nx * pFactor); 
    398404    endTime = time + (1<<Np)*(WORD)nx; 
    399     while (time < endTime) 
     405    while (time < endTime && Y < Yend) /* bennylp fix: protect Y */ 
    400406    { 
    401407        xp = &X[time>>Np];      /* Ptr to current input sample */ 
Note: See TracChangeset for help on using the changeset viewer.