Browse Source

CheckThousandsGroup: Avoid reading uninitialized data

For the case when word is smaller than 4 characters, we should not look at
the 3rd or 4th character before checking the previous ones, otherwise
we'd at best read uninitialized data, at worse non-existing data.
master
Samuel Thibault 3 years ago
parent
commit
f352f1e43f
2 changed files with 7 additions and 3 deletions
  1. 4
    3
      src/libespeak-ng/numbers.c
  2. 3
    0
      tests/translate.test

+ 4
- 3
src/libespeak-ng/numbers.c View File

// Is this a group of 3 digits which looks like a thousands group? // Is this a group of 3 digits which looks like a thousands group?
int ix; int ix;


if (IsDigit09(word[group_len]) || IsDigit09(-1))
return false;

for (ix = 0; ix < group_len; ix++) { for (ix = 0; ix < group_len; ix++) {
if (!IsDigit09(word[ix])) if (!IsDigit09(word[ix]))
return false; return false;
} }

if (IsDigit09(word[group_len]) || IsDigit09(-1))
return false;

return true; return true;
} }



+ 3
- 0
tests/translate.test View File

# bug: https://github.com/espeak-ng/espeak-ng/issues/471 # bug: https://github.com/espeak-ng/espeak-ng/issues/471
test_phon sk "sm'eju:tsa s'a tv'a:R" "☺" test_phon sk "sm'eju:tsa s'a tv'a:R" "☺"
test_phon sk "bl'ax sm'eju:tsa s'a tv'a:R" "blah ☺" test_phon sk "bl'ax sm'eju:tsa s'a tv'a:R" "blah ☺"

# https://github.com/espeak-ng/espeak-ng/pull/1148
test_phon fr "dY mil v'E~" "2020"

Loading…
Cancel
Save