diff options
| author | Eli Zaretskii | 2012-08-15 19:21:41 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2012-08-15 19:21:41 +0300 |
| commit | eb424fe3d660eebd9b74dd5d2875e2e4b7b3307f (patch) | |
| tree | 8b1a18195befbdd27478da75a623666c3d6a983d /src | |
| parent | 4e6a86c633a4ca3084a7bc30101f8b4acdd38d28 (diff) | |
| download | emacs-eb424fe3d660eebd9b74dd5d2875e2e4b7b3307f.tar.gz emacs-eb424fe3d660eebd9b74dd5d2875e2e4b7b3307f.zip | |
Fix bug #12196 with incorrect memory allocations for region-cache.
src/region-cache.c (move_cache_gap): Update gap_len using the actual
growth of the boundaries array. Do not change cache_len.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/region-cache.c | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index eb19fad9abe..20e5e4bdfbb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2012-08-15 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * region-cache.c (move_cache_gap): Update gap_len using the actual | ||
| 4 | growth of the boundaries array. Do not change cache_len. | ||
| 5 | (Bug#12196) | ||
| 6 | |||
| 1 | 2012-08-15 Dmitry Antipov <dmantipov@yandex.ru> | 7 | 2012-08-15 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 8 | ||
| 3 | Generalize and cleanup font subsystem checks. | 9 | Generalize and cleanup font subsystem checks. |
diff --git a/src/region-cache.c b/src/region-cache.c index 14b6233a5a5..d2bba8c11b2 100644 --- a/src/region-cache.c +++ b/src/region-cache.c | |||
| @@ -245,16 +245,16 @@ move_cache_gap (struct region_cache *c, ptrdiff_t pos, ptrdiff_t min_size) | |||
| 245 | when the portion after the gap is smallest. */ | 245 | when the portion after the gap is smallest. */ |
| 246 | if (gap_len < min_size) | 246 | if (gap_len < min_size) |
| 247 | { | 247 | { |
| 248 | ptrdiff_t i; | 248 | ptrdiff_t i, nboundaries = c->cache_len; |
| 249 | 249 | ||
| 250 | c->boundaries = | 250 | c->boundaries = |
| 251 | xpalloc (c->boundaries, &c->cache_len, min_size, -1, | 251 | xpalloc (c->boundaries, &nboundaries, min_size - gap_len, -1, |
| 252 | sizeof *c->boundaries); | 252 | sizeof *c->boundaries); |
| 253 | 253 | ||
| 254 | /* Some systems don't provide a version of the copy routine that | 254 | /* Some systems don't provide a version of the copy routine that |
| 255 | can be trusted to shift memory upward into an overlapping | 255 | can be trusted to shift memory upward into an overlapping |
| 256 | region. memmove isn't widely available. */ | 256 | region. memmove isn't widely available. */ |
| 257 | min_size -= gap_len; | 257 | min_size = nboundaries - c->cache_len - gap_len; |
| 258 | for (i = c->cache_len - 1; i >= gap_start; i--) | 258 | for (i = c->cache_len - 1; i >= gap_start; i--) |
| 259 | { | 259 | { |
| 260 | c->boundaries[i + min_size].pos = c->boundaries[i + gap_len].pos; | 260 | c->boundaries[i + min_size].pos = c->boundaries[i + gap_len].pos; |