]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug #6210.
authorEli Zaretskii <eliz@gnu.org>
Wed, 19 May 2010 07:22:41 +0000 (10:22 +0300)
committerEli Zaretskii <eliz@gnu.org>
Wed, 19 May 2010 07:22:41 +0000 (10:22 +0300)
 bidi.c (bidi_cache_shrink, bidi_cache_iterator_state): Fix
 reallocation of the cache.

src/ChangeLog
src/bidi.c

index 8a5d5b9fb84b10caa6fd00a832f1bc9204a98610..7c59d6b65455b16e10a88860380f0e54ff99466f 100644 (file)
@@ -1,3 +1,8 @@
+2010-05-19  Eli Zaretskii  <eliz@gnu.org>
+
+       * bidi.c (bidi_cache_shrink, bidi_cache_iterator_state): Fix
+       reallocation of the cache.  (Bug#6210)
+
 2010-05-19  Glenn Morris  <rgm@gnu.org>
 
        * s/msdos.h (ORDINARY_LINK): Move to sed2v2.inp.
index dbc95608fea785fe100dbe05266e196f85d398fd..6bcbf6f6aea98df254f37d37d58403ec50d8ceaf 100644 (file)
@@ -543,6 +543,7 @@ bidi_copy_it (struct bidi_it *to, struct bidi_it *from)
 #define BIDI_CACHE_CHUNK 200
 static struct bidi_it *bidi_cache;
 static size_t bidi_cache_size = 0;
+static size_t elsz = sizeof (struct bidi_it);
 static int bidi_cache_idx;     /* next unused cache slot */
 static int bidi_cache_last_idx;        /* slot of last cache hit */
 
@@ -558,8 +559,9 @@ bidi_cache_shrink (void)
 {
   if (bidi_cache_size > BIDI_CACHE_CHUNK)
     {
-      bidi_cache_size = BIDI_CACHE_CHUNK * sizeof (struct bidi_it);
-      bidi_cache = (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size);
+      bidi_cache_size = BIDI_CACHE_CHUNK;
+      bidi_cache =
+       (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size * elsz);
     }
   bidi_cache_reset ();
 }
@@ -688,9 +690,9 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, int resolved)
       /* Enlarge the cache as needed.  */
       if (idx >= bidi_cache_size)
        {
-         bidi_cache_size += BIDI_CACHE_CHUNK * sizeof (struct bidi_it);
+         bidi_cache_size += BIDI_CACHE_CHUNK;
          bidi_cache =
-           (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size);
+           (struct bidi_it *) xrealloc (bidi_cache, bidi_cache_size * elsz);
        }
       /* Character positions should correspond to cache positions 1:1.
         If we are outside the range of cached positions, the cache is