From: Eli Zaretskii Date: Thu, 28 Aug 2014 16:26:39 +0000 (+0300) Subject: Fix bug #18339 with segfault when $ is typed into empty LaTeX buffer. X-Git-Tag: emacs-24.3.94~72 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=74910c5d074b4173bd0469ca4e315e9deac78718;p=emacs.git Fix bug #18339 with segfault when $ is typed into empty LaTeX buffer. Back-ported from trunk revision-id: 2014-08-27T19:40:54Z!eliz@gnu.org src/syntax.c (scan_lists): Don't examine positions before BEGV. --- diff --git a/src/ChangeLog b/src/ChangeLog index 8ca95025019..b3744eb8b6e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2014-08-28 Eli Zaretskii + + * syntax.c (scan_lists): Don't examine positions before BEGV. + (Bug#18339) + 2014-08-25 Eli Zaretskii * conf_post.h (_GL_EXECINFO_INLINE) [MSDOS]: Don't define. diff --git a/src/syntax.c b/src/syntax.c index 0ee48bb3725..5e697d350ff 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -2859,10 +2859,13 @@ scan_lists (EMACS_INT from, EMACS_INT count, EMACS_INT depth, bool sexpflag) case Smath: if (!sexpflag) break; - temp_pos = dec_bytepos (from_byte); - UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); - if (from != stop && c == FETCH_CHAR_AS_MULTIBYTE (temp_pos)) - DEC_BOTH (from, from_byte); + if (from > BEGV) + { + temp_pos = dec_bytepos (from_byte); + UPDATE_SYNTAX_TABLE_BACKWARD (from - 1); + if (from != stop && c == FETCH_CHAR_AS_MULTIBYTE (temp_pos)) + DEC_BOTH (from, from_byte); + } if (mathexit) { mathexit = 0;