From 636fb09f80a8d6892d30dd5e66eca2c841cd5224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Holz?= Date: Wed, 19 Nov 2025 22:01:04 +0100 Subject: [PATCH] AK: Don't allow Vector::resize_and_keep_capacity() in the kernel This function doesn't propagate allocation failures. Replace the only current user of this function by using `shrink()` with `keep_capacity = true` instead. --- AK/Stack.h | 2 +- AK/Vector.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AK/Stack.h b/AK/Stack.h index acdc3830fa9..a1c618091e5 100644 --- a/AK/Stack.h +++ b/AK/Stack.h @@ -49,7 +49,7 @@ public: if (is_empty()) return false; - m_stack.resize_and_keep_capacity(m_stack.size() - 1); + m_stack.shrink(m_stack.size() - 1, true); return true; } diff --git a/AK/Vector.h b/AK/Vector.h index d62e4a6057e..13832443e68 100644 --- a/AK/Vector.h +++ b/AK/Vector.h @@ -788,13 +788,13 @@ public: { MUST(try_resize(new_size, keep_capacity)); } -#endif void resize_and_keep_capacity(size_t new_size) requires(!contains_reference) { MUST(try_resize_and_keep_capacity(new_size)); } +#endif void shrink_to_fit() {