mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:08:13 +00:00
Userland: Don't leak objects when constructor arguments throw
Similar to d253beb2f7
.
Found with Ali's clang-query script in Shell:
```
for $(find AK Userland -type f -name '*.h' -o -name '*.cpp') {
in_parallel -j 12 -- clang-query -p \
Build/lagom/compile_commands.json $it -c \
'm cxxNewExpr(has(cxxConstructExpr(hasAnyArgument(hasDescendant( \
allOf(isExpandedFromMacro("TRY"), stmtExpr()))))))' \
} | grep -v 'matches.' | tee results
```
This commit is contained in:
parent
d253beb2f7
commit
c145d5410c
4 changed files with 20 additions and 11 deletions
|
@ -19,14 +19,18 @@ namespace GUI {
|
|||
ErrorOr<NonnullRefPtr<InputBox>> InputBox::create(Window* parent_window, String text_value, StringView prompt, StringView title, InputType input_type, RefPtr<Gfx::Bitmap const> icon)
|
||||
{
|
||||
VERIFY(input_type != InputType::Numeric);
|
||||
auto box = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) InputBox(parent_window, text_value, TRY(String::from_utf8(title)), TRY(String::from_utf8(prompt)), input_type, move(icon))));
|
||||
auto title_string = TRY(String::from_utf8(title));
|
||||
auto prompt_string = TRY(String::from_utf8(prompt));
|
||||
auto box = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) InputBox(parent_window, text_value, title_string, prompt_string, input_type, move(icon))));
|
||||
TRY(box->build());
|
||||
return box;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<InputBox>> InputBox::create_numeric(Window* parent_window, int value, StringView title, StringView prompt, RefPtr<Gfx::Bitmap const> icon)
|
||||
{
|
||||
auto box = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) InputBox(parent_window, value, TRY(String::from_utf8(title)), TRY(String::from_utf8(prompt)), move(icon))));
|
||||
auto title_string = TRY(String::from_utf8(title));
|
||||
auto prompt_string = TRY(String::from_utf8(prompt));
|
||||
auto box = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) InputBox(parent_window, value, title_string, prompt_string, move(icon))));
|
||||
TRY(box->build());
|
||||
return box;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue