From 51f30bc52daf551f3c433b80f598eb52dca71033 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 18 Aug 2011 23:58:42 -0700 Subject: [PATCH] * bidi.c (bidi_cache_shrink): update size after realloc --- src/ChangeLog | 1 + src/bidi.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 36bf95e9aa7..1db99549c60 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -59,6 +59,7 @@ (bidi_cache_ensure_space, bidi_shelve_cache): Use it. (bidi_cache_ensure_space): Avoid integer overflow when allocating. + * bidi.c (bidi_cache_shrink): * buffer.c (overlays_at, overlays_in, record_overlay_string) (overlay_strings): Don't update size of array until after memory allocation succeeds, diff --git a/src/bidi.c b/src/bidi.c index d8742540fc7..769a14f089b 100644 --- a/src/bidi.c +++ b/src/bidi.c @@ -350,9 +350,9 @@ bidi_cache_shrink (void) { if (bidi_cache_size > BIDI_CACHE_CHUNK) { - bidi_cache_size = BIDI_CACHE_CHUNK; bidi_cache = - (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size * elsz); + (struct bidi_it *) xrealloc (bidi_cache, BIDI_CACHE_CHUNK * elsz); + bidi_cache_size = BIDI_CACHE_CHUNK; } bidi_cache_reset (); } -- 2.39.2