From b998ada9d259f4f39cb5ed3ee121f6b447d96c44 Mon Sep 17 00:00:00 2001 From: Bruno Raoult Date: Sat, 11 Dec 2021 10:04:22 +0100 Subject: [PATCH] fix possible leak if wrong input --- 2021/day10/aoc-c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2021/day10/aoc-c.c b/2021/day10/aoc-c.c index 9e01a73..89a67ba 100644 --- a/2021/day10/aoc-c.c +++ b/2021/day10/aoc-c.c @@ -68,7 +68,7 @@ static s64 match_incomplete() s64 res = 0; while ((co = pop())) { - for (size_t i = 0; i < sizeof(syntax); ++i) { + for (size_t i = 0; i < sizeof(syntax) / sizeof(struct match); ++i) { if (co == syntax[i].open) { res = res * 5 + syntax[i].value_incomplete; break;