diff options
| author | Chong Yidong | 2008-03-26 22:54:40 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-03-26 22:54:40 +0000 |
| commit | 381880b0ae114be0d4fa9ae1737bdce9cb62f941 (patch) | |
| tree | 01d93ea6516218d67844db613f2b0ed9d77d0adc /src | |
| parent | 3cf8cdfbc6ac552e03de339a3fa2175299279f44 (diff) | |
| download | emacs-381880b0ae114be0d4fa9ae1737bdce9cb62f941.tar.gz emacs-381880b0ae114be0d4fa9ae1737bdce9cb62f941.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.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/regex.c b/src/regex.c index eca78f2ab94..cbc67568743 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -1854,8 +1854,10 @@ static int analyse_first _RE_ARGS ((re_char *p, re_char *pend, | |||
| 1854 | being larger than MAX_BUF_SIZE, then flag memory exhausted. */ | 1854 | being larger than MAX_BUF_SIZE, then flag memory exhausted. */ |
| 1855 | #if __BOUNDED_POINTERS__ | 1855 | #if __BOUNDED_POINTERS__ |
| 1856 | # define SET_HIGH_BOUND(P) (__ptrhigh (P) = __ptrlow (P) + bufp->allocated) | 1856 | # define SET_HIGH_BOUND(P) (__ptrhigh (P) = __ptrlow (P) + bufp->allocated) |
| 1857 | # define MOVE_BUFFER_POINTER(P) \ | 1857 | # define MOVE_BUFFER_POINTER(P) \ |
| 1858 | (__ptrlow (P) += incr, SET_HIGH_BOUND (P), __ptrvalue (P) += incr) | 1858 | (__ptrlow (P) = new_buffer + (__ptrlow (P) - old_buffer), \ |
| 1859 | SET_HIGH_BOUND (P), \ | ||
| 1860 | __ptrvalue (P) = new_buffer + (__ptrvalue (P) - old_buffer)) | ||
| 1859 | # define ELSE_EXTEND_BUFFER_HIGH_BOUND \ | 1861 | # define ELSE_EXTEND_BUFFER_HIGH_BOUND \ |
| 1860 | else \ | 1862 | else \ |
| 1861 | { \ | 1863 | { \ |
| @@ -1869,12 +1871,12 @@ static int analyse_first _RE_ARGS ((re_char *p, re_char *pend, | |||
| 1869 | SET_HIGH_BOUND (pending_exact); \ | 1871 | SET_HIGH_BOUND (pending_exact); \ |
| 1870 | } | 1872 | } |
| 1871 | #else | 1873 | #else |
| 1872 | # define MOVE_BUFFER_POINTER(P) (P) += incr | 1874 | # define MOVE_BUFFER_POINTER(P) ((P) = new_buffer + ((P) - old_buffer)) |
| 1873 | # define ELSE_EXTEND_BUFFER_HIGH_BOUND | 1875 | # define ELSE_EXTEND_BUFFER_HIGH_BOUND |
| 1874 | #endif | 1876 | #endif |
| 1875 | #define EXTEND_BUFFER() \ | 1877 | #define EXTEND_BUFFER() \ |
| 1876 | do { \ | 1878 | do { \ |
| 1877 | re_char *old_buffer = bufp->buffer; \ | 1879 | unsigned char *old_buffer = bufp->buffer; \ |
| 1878 | if (bufp->allocated == MAX_BUF_SIZE) \ | 1880 | if (bufp->allocated == MAX_BUF_SIZE) \ |
| 1879 | return REG_ESIZE; \ | 1881 | return REG_ESIZE; \ |
| 1880 | bufp->allocated <<= 1; \ | 1882 | bufp->allocated <<= 1; \ |
| @@ -1886,7 +1888,7 @@ static int analyse_first _RE_ARGS ((re_char *p, re_char *pend, | |||
| 1886 | /* If the buffer moved, move all the pointers into it. */ \ | 1888 | /* If the buffer moved, move all the pointers into it. */ \ |
| 1887 | if (old_buffer != bufp->buffer) \ | 1889 | if (old_buffer != bufp->buffer) \ |
| 1888 | { \ | 1890 | { \ |
| 1889 | int incr = bufp->buffer - old_buffer; \ | 1891 | unsigned char *new_buffer = bufp->buffer; \ |
| 1890 | MOVE_BUFFER_POINTER (b); \ | 1892 | MOVE_BUFFER_POINTER (b); \ |
| 1891 | MOVE_BUFFER_POINTER (begalt); \ | 1893 | MOVE_BUFFER_POINTER (begalt); \ |
| 1892 | if (fixup_alt_jump) \ | 1894 | if (fixup_alt_jump) \ |