ALL: fix memory leaks

This commit is contained in:
hasufell 2014-05-30 19:54:50 +02:00
parent 8871b496c2
commit 7f23aa2a35
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
3 changed files with 9 additions and 5 deletions

View File

@ -397,7 +397,7 @@ poly_to_base64(fmpz_poly_t poly,
result_string->ptr = base64_string;
result_string->len = strlen(base64_string);
free(string_rep);
string_delete(string_rep);
free(tmp);
return result_string;

View File

@ -121,6 +121,7 @@ export_priv_key(char const * const filename,
priv_string = poly_to_base64(priv_u, ctx);
write_file(priv_string, filename);
fmpz_poly_clear(priv_u);
string_delete(priv_string);
}
@ -145,7 +146,7 @@ import_public_key(char const * const filename,
fmpz_poly_set(pub, **imported);
string_delete(pub_string);
poly_delete(**imported);
poly_delete_array(imported);
free(imported);
}
@ -185,7 +186,7 @@ import_priv_key(char const * const filename,
cleanup:
string_delete(pub_string);
poly_delete(**imported);
poly_delete_array(imported);
free(imported);
}

View File

@ -117,10 +117,13 @@ poly_delete_array(fmpz_poly_t **poly_array)
while(poly_array[i]) {
poly_delete(*(poly_array[i]));
free(*(poly_array[i]));
free(poly_array[i]);
i++;
}
free(poly_array);
/* avoid double free */
if (i > 1)
free(poly_array);
}
/*------------------------------------------------------------------------*/