From 0c62846bbdd22f9b2b6c3cbe39c49d68c6cf9893 Mon Sep 17 00:00:00 2001 From: Benjamin Kraft Date: Thu, 8 Dec 2022 20:38:55 +0100 Subject: [PATCH] SEGV fix --- src/days/05/Day05.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/days/05/Day05.cpp b/src/days/05/Day05.cpp index e01ccb3..bd79db0 100644 --- a/src/days/05/Day05.cpp +++ b/src/days/05/Day05.cpp @@ -51,9 +51,12 @@ vector Day05::parseStacks(){ for (int i = 0; i < stackCount; i++){ parsed.emplace_back(); int index = 1 + 4 * i; + for (size_t line = endIndex - 2; input[line].size() > index && input[line][index] != ' '; line--){ Crate crate = input[line][index]; parsed[i].push_back(crate); + if (line == 0) + break; } }