Thursday, June 6, 2024

minor bug in control_loop.h

Hi,

Found a minor (but annoying to track down!) bug in include/gnuradio/blocks/control_loop.h.

If the input is NaN, then neither of the if statements evaluates to true, and the program segfaults.

My company policy requires jumping through some hoops to make a direct github contribution. 

I suggest a patch:

instead of 'int index', make it 'uint8_t index' and that will solve the segfault.

static inline float tanhf_lut(float x)
{
    if (x > 2)
        return 1;
    else if (x <= -2)
        return -1;
    else {
        int index = 128 + 64 * x;
        return tanh_lut_table[index];
    }
}

Eugene.

No comments:

Post a Comment