Index: malloc.c
===================================================================
RCS file: /home/kde/kdelibs/kdecore/malloc/malloc.c,v
retrieving revision 1.4
diff -u -r1.4 malloc.c
--- malloc.c	2002/03/02 16:10:35	1.4
+++ malloc.c	2002/04/16 20:35:59
@@ -2934,7 +2934,10 @@
             p = chunk_at_offset(p, -((long) prevsize));
             unlink(p, bck, fwd);
           }
-          
+          else if (nextp && nextp == nextp->fd) {
+            break; /* avoid an infinite loop */
+          }
+
           if (nextchunk != av->top) {
             nextinuse = inuse_bit_at_offset(nextchunk, nextsize);
             set_head(nextchunk, nextsize);
@@ -2960,6 +2963,10 @@
             av->top = p;
           }
           
+          if (nextp && nextp->fd && nextp->fd->fd == nextp) {
+            break; /* avoid an infinite loop */
+          }
+
         } while ( (p = nextp) != 0);
         
       }
