1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:18:12 +00:00

LibJS: Avoid crash on empty stack trace

We were trying to stringify the stack trace without the last element,
leading to a loop bound of (size_t)(0 - 1) and accessing m_traceback[0]
out-of-bounds.

Instead, just return an empty string in that case.

Fixes #21747
This commit is contained in:
Simon Wanner 2023-11-02 16:11:33 +01:00 committed by Andreas Kling
parent 38531ce7cf
commit 1030776f92

View file

@ -93,6 +93,9 @@ void Error::populate_stack()
String Error::stack_string(CompactTraceback compact) const
{
if (m_traceback.is_empty())
return {};
StringBuilder stack_string_builder;
// Note: We roughly follow V8's formatting