aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChong Yidong2008-03-26 22:57:42 +0000
committerChong Yidong2008-03-26 22:57:42 +0000
commita0139331d2fc5f32e9fdd5da6fe8edb0bf836e44 (patch)
treeb04a93ab7c6f028245d19f61994a706d2416dcff /src
parent5070a9f52e35844023f2b14f18b2e76d6bba5e38 (diff)
downloademacs-a0139331d2fc5f32e9fdd5da6fe8edb0bf836e44.tar.gz
emacs-a0139331d2fc5f32e9fdd5da6fe8edb0bf836e44.zip
(EXTEND_BUFFER): Change order of pointer addition operations, to avoid
having the difference between pointers overflow.
Diffstat (limited to 'src')
-rw-r--r--src/regex.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/regex.c b/src/regex.c
index 6435133c96f..e793df3da81 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -1832,8 +1832,10 @@ static int analyse_first _RE_ARGS ((re_char *p, re_char *pend,
1832 being larger than MAX_BUF_SIZE, then flag memory exhausted. */ 1832 being larger than MAX_BUF_SIZE, then flag memory exhausted. */
1833#if __BOUNDED_POINTERS__ 1833#if __BOUNDED_POINTERS__
1834# define SET_HIGH_BOUND(P) (__ptrhigh (P) = __ptrlow (P) + bufp->allocated) 1834# define SET_HIGH_BOUND(P) (__ptrhigh (P) = __ptrlow (P) + bufp->allocated)
1835# define MOVE_BUFFER_POINTER(P) \ 1835# define MOVE_BUFFER_POINTER(P) \
1836 (__ptrlow (P) += incr, SET_HIGH_BOUND (P), __ptrvalue (P) += incr) 1836 (__ptrlow (P) = new_buffer + (__ptrlow (P) - old_buffer), \
1837 SET_HIGH_BOUND (P), \
1838 __ptrvalue (P) = new_buffer + (__ptrvalue (P) - old_buffer))
1837# define ELSE_EXTEND_BUFFER_HIGH_BOUND \ 1839# define ELSE_EXTEND_BUFFER_HIGH_BOUND \
1838 else \ 1840 else \
1839 { \ 1841 { \
@@ -1847,12 +1849,12 @@ static int analyse_first _RE_ARGS ((re_char *p, re_char *pend,
1847 SET_HIGH_BOUND (pending_exact); \ 1849 SET_HIGH_BOUND (pending_exact); \
1848 } 1850 }
1849#else 1851#else
1850# define MOVE_BUFFER_POINTER(P) (P) += incr 1852# define MOVE_BUFFER_POINTER(P) ((P) = new_buffer + ((P) - old_buffer))
1851# define ELSE_EXTEND_BUFFER_HIGH_BOUND 1853# define ELSE_EXTEND_BUFFER_HIGH_BOUND
1852#endif 1854#endif
1853#define EXTEND_BUFFER() \ 1855#define EXTEND_BUFFER() \
1854 do { \ 1856 do { \
1855 re_char *old_buffer = bufp->buffer; \ 1857 unsigned char *old_buffer = bufp->buffer; \
1856 if (bufp->allocated == MAX_BUF_SIZE) \ 1858 if (bufp->allocated == MAX_BUF_SIZE) \
1857 return REG_ESIZE; \ 1859 return REG_ESIZE; \
1858 bufp->allocated <<= 1; \ 1860 bufp->allocated <<= 1; \
@@ -1864,7 +1866,7 @@ static int analyse_first _RE_ARGS ((re_char *p, re_char *pend,
1864 /* If the buffer moved, move all the pointers into it. */ \ 1866 /* If the buffer moved, move all the pointers into it. */ \
1865 if (old_buffer != bufp->buffer) \ 1867 if (old_buffer != bufp->buffer) \
1866 { \ 1868 { \
1867 int incr = bufp->buffer - old_buffer; \ 1869 unsigned char *new_buffer = bufp->buffer; \
1868 MOVE_BUFFER_POINTER (b); \ 1870 MOVE_BUFFER_POINTER (b); \
1869 MOVE_BUFFER_POINTER (begalt); \ 1871 MOVE_BUFFER_POINTER (begalt); \
1870 if (fixup_alt_jump) \ 1872 if (fixup_alt_jump) \