alloc: fix bug in tiny allocator.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 27 Jul 2010 05:32:02 +0000 (15:02 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 27 Jul 2010 05:32:02 +0000 (15:02 +0930)
ccan/alloc/tiny.c

index feffa618e0cf629d9edc1822ed89d70ba8dde290..d782899de3d0639c11bd67d6a54a7f42e1d04f60 100755 (executable)
@@ -186,7 +186,7 @@ void *tiny_alloc_get(void *pool, unsigned long poolsize,
                if (long_enough(off, len, size, align)) {
                        /* Move every successive entry down. */
                        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);
                        goto found;
                }