This fixes a off-by-one buffer overrun bug introduced in
2017-06-04T15:39:37Z!eggert@cs.ucla.edu. Problem uncovered by an
experimental version of Emacs built with -fcheck-pointer-bounds
and running on Intel MPX hardware.
* src/editfns.c (styled_format): Avoid overrunning internal buffers.
else if (discarded[bytepos] == 1)
{
position++;
- if (translated == info[fieldn].start)
+ if (fieldn < nspec && translated == info[fieldn].start)
{
translated += info[fieldn].end - info[fieldn].start;
fieldn++;
else if (discarded[bytepos] == 1)
{
position++;
- if (translated == info[fieldn].start)
+ if (fieldn < nspec && translated == info[fieldn].start)
{
translated += info[fieldn].end - info[fieldn].start;
fieldn++;