Menu

#1267 Uninitialized value at idwt

2.6.0.RC0
closed-fixed
clynejp
None
7
2016-11-14
2016-07-21
Samuel Li
No

Hello John,

I found a bug in MatWaveDwt.cpp with uninitialized values.

It's at the idwt_template() function, about the last element of cDTemp array when cD was originally in odd length.

Use an example of input array with length 19. After forward transform, cA has length 10, and cD has length 9. Then we enter the idwt_template() function.

Given the bior4.4 wavelet kernel and all the boundary extensions considered, in
line 732, extendLen = 2;
line 735, cATempLen = 14;
line 739, cDTempLen = 14.

cDTemp is allocated memory of length 14 in line 747 as well.

cDTemp is then extended from cD at line 788. Note cD has size 9, and is extended to size (9+2+2)=13 at the place where cDTemp is pointing to. However, cDTemp is later used as if it has length cDTempLen=14 in inverse_xform_odd(), though the 14th element is never initialized.

I think an easy fix could be adding the following code after line 792:

if( L[1] + extendLen + extendLen < cDTempLen )
{
assert( L[1] + extendLen + extendLen == cDTempLen - 1 );
cDTemp[ cDTempLen-1 ] = 0.0;
}

Thanks,
Samuel

Related

Bugs: #1267

Discussion

  • clynejp

    clynejp - 2016-07-27

    Thanks, Samuel. We’ll get this taken care of for the next release.

    jc

    On Jul 21, 2016, at 1:53 PM, Samuel Li shaomeng@users.sf.net wrote:

    [bugs:#1267] Uninitialized value at idwt

    Status: open
    Group: 2.5.0
    Created: Thu Jul 21, 2016 07:53 PM UTC by Samuel Li
    Last Updated: Thu Jul 21, 2016 07:53 PM UTC
    Owner: clynejp

    Hello John,

    I found a bug in MatWaveDwt.cpp with uninitialized values.

    It's at the idwt_template() function, about the last element of cDTemp array when cD was originally in odd length.

    Use an example of input array with length 19. After forward transform, cA has length 10, and cD has length 9. Then we enter the idwt_template() function.

    Given the bior4.4 wavelet kernel and all the boundary extensions considered, in
    line 732, extendLen = 2;
    line 735, cATempLen = 14;
    line 739, cDTempLen = 14.

    cDTemp is allocated memory of length 14 in line 747 as well.

    cDTemp is then extended from cD at line 788. Note cD has size 9, and is extended to size (9+2+2)=13 at the place where cDTemp is pointing to. However, cDTemp is later used as if it has length cDTempLen=14 in inverse_xform_odd(), though the 14th element is never initialized.

    I think an easy fix could be adding the following code after line 792:

    if( L[1] + extendLen + extendLen < cDTempLen )
    {
    assert( L[1] + extendLen + extendLen == cDTempLen - 1 );
    cDTemp[ cDTempLen-1 ] = 0.0;
    }

    Thanks,
    Samuel

    Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/vapor/bugs/1267/

    To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

    John Clyne
    National Center for Atmospheric Research
    303.497.1236 (w), 303.809.1922 (c)
    clyne@ucar.edu

     

    Related

    Bugs: #1267

  • Samuel Li

    Samuel Li - 2016-10-14
    This bug is not fixed.
    
     
  • clynejp

    clynejp - 2016-10-17
    • Priority: 5 --> 7
     
  • clynejp

    clynejp - 2016-10-20
    • status: open --> closed-fixed
     
  • clynejp

    clynejp - 2016-11-14
    • Group: 2.5.0 --> 2.6.0.RC0
     

Log in to post a comment.

MongoDB Logo MongoDB