Commit eb424fe3 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

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.
parent 4e6a86c6
2012-08-15 Eli Zaretskii <eliz@gnu.org>
* region-cache.c (move_cache_gap): Update gap_len using the actual
growth of the boundaries array. Do not change cache_len.
(Bug#12196)
2012-08-15 Dmitry Antipov <dmantipov@yandex.ru> 2012-08-15 Dmitry Antipov <dmantipov@yandex.ru>
Generalize and cleanup font subsystem checks. Generalize and cleanup font subsystem checks.
......
...@@ -245,16 +245,16 @@ move_cache_gap (struct region_cache *c, ptrdiff_t pos, ptrdiff_t min_size) ...@@ -245,16 +245,16 @@ move_cache_gap (struct region_cache *c, ptrdiff_t pos, ptrdiff_t min_size)
when the portion after the gap is smallest. */ when the portion after the gap is smallest. */
if (gap_len < min_size) if (gap_len < min_size)
{ {
ptrdiff_t i; ptrdiff_t i, nboundaries = c->cache_len;
c->boundaries = c->boundaries =
xpalloc (c->boundaries, &c->cache_len, min_size, -1, xpalloc (c->boundaries, &nboundaries, min_size - gap_len, -1,
sizeof *c->boundaries); sizeof *c->boundaries);
/* Some systems don't provide a version of the copy routine that /* Some systems don't provide a version of the copy routine that
can be trusted to shift memory upward into an overlapping can be trusted to shift memory upward into an overlapping
region. memmove isn't widely available. */ region. memmove isn't widely available. */
min_size -= gap_len; min_size = nboundaries - c->cache_len - gap_len;
for (i = c->cache_len - 1; i >= gap_start; i--) for (i = c->cache_len - 1; i >= gap_start; i--)
{ {
c->boundaries[i + min_size].pos = c->boundaries[i + gap_len].pos; c->boundaries[i + min_size].pos = c->boundaries[i + gap_len].pos;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment