LibJS: Throw RangeError in StringPrototype::repeat if OOM

currently crashes with an assertion failure in `String::repeated` if
malloc can't serve a `count * input_size` sized request, so add
`String::repeated_with_error` to propagate the error.
This commit is contained in:
Jess
2024-04-18 21:35:35 +12:00
committed by Tim Flynn
parent f4c8f1a346
commit ecb7d4b40f
5 changed files with 16 additions and 5 deletions

View File

@@ -79,7 +79,7 @@ public:
static ErrorOr<String> repeated(u32 code_point, size_t count);
// Creates a new String from another string, repeated N times.
static String repeated(String const&, size_t count);
static ErrorOr<String> repeated(String const&, size_t count);
// Creates a new String by case-transforming this String. Using these methods require linking LibUnicode into your application.
ErrorOr<String> to_lowercase(Optional<StringView> const& locale = {}) const;