Open gamax92 opened 8 years ago
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.)
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.