Skip to content

Commit 1bce159

Browse files
committed
LibGfx/JBIG2Loader: Use try_append more
The size of these vectors depends on values in the input data, so try_append is appropriate. No behavior change.
1 parent c7a5bdb commit 1bce159

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Userland/Libraries/LibGfx/ImageFormats/JBIG2Loader.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,13 +2049,13 @@ static ErrorOr<Vector<BilevelSubImage>> symbol_dictionary_decoding_procedure(Sym
20492049
// FIXME: Doing this eagerly is pretty wasteful. Decode on demand instead?
20502050
if (!inputs.uses_huffman_encoding || inputs.uses_refinement_or_aggregate_coding) {
20512051
auto bitmap = TRY(read_symbol_bitmap(symbol_width, height_class_height));
2052-
new_symbols.append(bitmap->as_subbitmap());
2052+
TRY(new_symbols.try_append(bitmap->as_subbitmap()));
20532053
}
20542054

20552055
// "iii) If SDHUFF is 1 and SDREFAGG is 0, then set:
20562056
// SDNEWSYMWIDTHS[NSYMSDECODED] = SYMWIDTH"
20572057
if (inputs.uses_huffman_encoding && !inputs.uses_refinement_or_aggregate_coding)
2058-
new_symbol_widths.append(symbol_width);
2058+
TRY(new_symbol_widths.try_append(symbol_width));
20592059

20602060
// "iv) Set:
20612061
// NSYMSDECODED = NSYMSDECODED + 1"
@@ -2082,7 +2082,7 @@ static ErrorOr<Vector<BilevelSubImage>> symbol_dictionary_decoding_procedure(Sym
20822082
for (size_t i = height_class_first_symbol; i < number_of_symbols_decoded; ++i) {
20832083
auto width = new_symbol_widths[i];
20842084
IntRect symbol_rect { static_cast<int>(current_column), 0, static_cast<int>(width), static_cast<int>(height_class_height) };
2085-
new_symbols.append(collective_bitmap->subbitmap(symbol_rect));
2085+
TRY(new_symbols.try_append(collective_bitmap->subbitmap(symbol_rect)));
20862086
current_column += width;
20872087
}
20882088
}
@@ -2144,13 +2144,13 @@ static ErrorOr<Vector<BilevelSubImage>> symbol_dictionary_decoding_procedure(Sym
21442144
// SDEXSYMS[J] = SDINSYMS[I]
21452145
// J = J + 1"
21462146
if (i < inputs.input_symbols.size())
2147-
exported_symbols.append(inputs.input_symbols[i]);
2147+
TRY(exported_symbols.try_append(inputs.input_symbols[i]));
21482148

21492149
// "b) If I >= SDNUMINSYMS then set:
21502150
// SDEXSYMS[J] = SDNEWSYMS[I – SDNUMINSYMS]
21512151
// J = J + 1"
21522152
if (i >= inputs.input_symbols.size())
2153-
exported_symbols.append(move(new_symbols[i - inputs.input_symbols.size()]));
2153+
TRY(exported_symbols.try_append(move(new_symbols[i - inputs.input_symbols.size()])));
21542154
}
21552155

21562156
if (exported_symbols.size() != inputs.number_of_exported_symbols)

0 commit comments

Comments
 (0)