AdolfVonKleist / Phonetisaurus

Phonetisaurus G2P
BSD 3-Clause "New" or "Revised" License
453 stars 122 forks source link

Vector overrun #76

Open danijel3 opened 2 years ago

danijel3 commented 2 years ago

This piece of code causes a crash when compiled in Visual Studio C++:

https://github.com/AdolfVonKleist/Phonetisaurus/blob/f08d3dfb10b8d619e665a9581d2a327bcc2504f7/src/include/PhonetisaurusRex.h#L117

Interestingly, it seems to work under Linux. In any case, this is a little iffy approach, since referencing the brackets operator beyond the vector is generally incorrect, even if it is only used as a last iterator in this case. A fix for this line is to simply use:

vector<int> subv (word.begin()+i, word.begin()+i+j);