Return err when alloc failure (#1567)

This commit is contained in:
Amos Bird
2021-05-15 10:51:07 +08:00
committed by GitHub
parent e4150443ca
commit 8df32cea33
5 changed files with 24 additions and 14 deletions
+4 -2
View File
@@ -10,8 +10,10 @@ simdjson_warn_unused error_code implementation::create_dom_parser_implementation
) const noexcept {
dst.reset( new (std::nothrow) dom_parser_implementation() );
if (!dst) { return MEMALLOC; }
dst->set_capacity(capacity);
dst->set_max_depth(max_depth);
if (auto err = dst->set_capacity(capacity))
return err;
if (auto err = dst->set_max_depth(max_depth))
return err;
return SUCCESS;
}