]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug in i18n/l10n optimization
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 3 Dec 2017 05:31:24 +0000 (21:31 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 3 Dec 2017 05:32:26 +0000 (21:32 -0800)
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.

src/editfns.c

index f275f33fc52fab487169850b578d9f7689a87a35..f7c26b900a065af50d8e9cdab46f942036a07f6d 100644 (file)
@@ -4919,7 +4919,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
                  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++;
@@ -4939,7 +4939,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
                  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++;