Skip to content

Commit

Permalink
fix: Don't crash on malloc failures in bin_unpack.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Jan 19, 2025
1 parent be457d5 commit edb4dfc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions toxcore/bin_unpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ bool bin_unpack_bin(Bin_Unpack *bu, uint8_t **data_ptr, uint32_t *data_length_pt
}
uint8_t *const data = (uint8_t *)mem_balloc(bu->mem, bin_size);

if (data == nullptr) {
return false;

Check warning on line 129 in toxcore/bin_unpack.c

View check run for this annotation

Codecov / codecov/patch

toxcore/bin_unpack.c#L129

Added line #L129 was not covered by tests
}

if (!bin_unpack_bin_b(bu, data, bin_size)) {
mem_delete(bu->mem, data);
return false;
Expand Down

0 comments on commit edb4dfc

Please sign in to comment.