about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2018-04-17 15:18:49 -0400
committerRich Felker <dalias@aerifal.cx>2018-04-17 19:23:01 -0400
commit14032c30e2d41e5c0dac25d399f7086f74d4e0c8 (patch)
tree085e4b76575b4fa62077c72e9595d9b44e60d9da /src
parentce7ae11acfd9db8eb92cc6823c132e1825918d92 (diff)
downloadmusl-14032c30e2d41e5c0dac25d399f7086f74d4e0c8.tar.gz
musl-14032c30e2d41e5c0dac25d399f7086f74d4e0c8.tar.xz
musl-14032c30e2d41e5c0dac25d399f7086f74d4e0c8.zip
comment __malloc_donate overflow logic
Diffstat (limited to 'src')
-rw-r--r--src/malloc/malloc.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/malloc/malloc.c b/src/malloc/malloc.c
index 6605ec3a..991300cc 100644
--- a/src/malloc/malloc.c
+++ b/src/malloc/malloc.c
@@ -563,6 +563,9 @@ void __malloc_donate(char *start, char *end)
 	size_t align_start_up = (SIZE_ALIGN-1) & (-(uintptr_t)start - OVERHEAD);
 	size_t align_end_down = (SIZE_ALIGN-1) & (uintptr_t)end;
 
+	/* Getting past this condition ensures that the padding for alignment
+	 * and header overhead will not overflow and will leave a nonzero
+	 * multiple of SIZE_ALIGN bytes between start and end. */
 	if (end - start <= OVERHEAD + align_start_up + align_end_down)
 		return;
 	start += align_start_up + OVERHEAD;