Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer underread problems #3

Open
gamax92 opened this issue May 15, 2016 · 1 comment
Open

Buffer underread problems #3

gamax92 opened this issue May 15, 2016 · 1 comment

Comments

@gamax92
Copy link

gamax92 commented May 15, 2016

// Removed debugging statements
        if ((flags2[index] & 16) != 0) {
            index = phonemeindex[X - 1];
            if ((flags[index] & 2) != 0);
            phonemeLength[X] -= 2;
        }

if X is set to 0 (verified that it can be), this section of code ends up reading phonemeindex[-1]

Also, I'm not sure if that phonemeLength[X] -= 2; bit should be under the if statement, according to the debugging statement it seems like it should be but currently it's always applied.
Took a look at e23a526 at line 890, and inside Code48619 you can see it was originally under the check.

EDIT: I'm noticing a lot more positions that it can potentially underread from, basically anything that happens to have a [variable-1] in it's index.

@gamax92 gamax92 changed the title Buffer under read in AdjustLengths Buffer underread problems May 15, 2016
@Felice-Enellen
Copy link

Felice-Enellen commented Aug 19, 2017

Similar issue near the bottom of sam.c, where three debug prints have been added before the only statement in a single-statement if block without curly braces, thus making the statement execute unconditionally.

            if((flags[index] & 2) != 0)
                             // Rule: <LIQUID CONSONANT> <DIPHTONG>

if (debug) printf("RULE: <LIQUID CONSONANT> <DIPHTONG> - decrease by 2\n");
if (debug) printf("PRE\n");
if (debug) printf("phoneme %d (%c%c) length %d\n", X, signInputTable1[phonemeindex[X]], signInputTable2[phonemeindex[X]], phonemeLength[X]);

             // decrease the phoneme length by 2 frames (20 ms)
             phonemeLength[X] -= 2;

Notice without the debug prints, the -=2 is controlled by the if(), but with them it runs on its own.

There could easily be more of these.

(This is why I always implemented a "always use curlies, no matter how many statements are in the block" rule at work whenever I had the authority to do so.)

earlephilhower added a commit to earlephilhower/SAM that referenced this issue Oct 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants