Skip to content

Commit

Permalink
Do not segfault when trying to bs_size_free NULL
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechtrefny committed Oct 11, 2017
1 parent ef3ed83 commit 1954ff0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/bs_size.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,11 @@ static void mul_64bit (mpz_t rop, const mpz_t op1, uint64_t op2) {
* Clears @size and frees the allocated resources.
*/
void bs_size_free (BSSize size) {
mpz_clear (size->bytes);
free (size);
if (size) {
mpz_clear (size->bytes);
free (size);
}
return;
}

/**
Expand Down

0 comments on commit 1954ff0

Please sign in to comment.