Browse Source

alloc: fix bug in tiny allocator.

Rusty Russell 15 years ago
parent
commit
774ce0359d
1 changed files with 1 additions and 1 deletions
  1. 1 1
      ccan/alloc/tiny.c

+ 1 - 1
ccan/alloc/tiny.c

@@ -186,7 +186,7 @@ void *tiny_alloc_get(void *pool, unsigned long poolsize,
 		if (long_enough(off, len, size, align)) {
 		if (long_enough(off, len, size, align)) {
 			/* Move every successive entry down. */
 			/* Move every successive entry down. */
 			memmove(arr + fa_off, arr + fa_off + fa_hdrlen,
 			memmove(arr + fa_off, arr + fa_off + fa_hdrlen,
-				freelen - fa_hdrlen);
+				freelen - (fa_off + fa_hdrlen));
 			memset(arr + freelen - fa_hdrlen, 0, fa_hdrlen);
 			memset(arr + freelen - fa_hdrlen, 0, fa_hdrlen);
 			goto found;
 			goto found;
 		}
 		}