From d3bab3fd88d52b27688537a7493afbdd75932af6 Mon Sep 17 00:00:00 2001 From: tomoron Date: Mon, 9 Dec 2024 14:31:29 +0100 Subject: [PATCH] fix invalid read --- 2024/9/part2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/2024/9/part2.c b/2024/9/part2.c index 91fc4af..0a84c94 100644 --- a/2024/9/part2.c +++ b/2024/9/part2.c @@ -6,7 +6,7 @@ /* By: tomoron +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/07/17 23:03:36 by tomoron #+# #+# */ -/* Updated: 2024/12/09 14:24:07 by tomoron ### ########.fr */ +/* Updated: 2024/12/09 14:30:17 by tomoron ### ########.fr */ /* */ /* ************************************************************************** */ @@ -90,7 +90,7 @@ static void frag_disk(int *disk, int len) while(*end_ptr == -1 && end_ptr > disk) end_ptr--; tmp = *end_ptr; - while(end_ptr[-bloc_len] == tmp && end_ptr > disk) + while(end_ptr[-bloc_len] == tmp && (end_ptr - bloc_len) > disk) bloc_len++; fs_ptr = find_place(disk, bloc_len, end_ptr); while(fs_ptr && bloc_len > 0)