Mailing List Archive

Memory leak in gcry_ac_key_destroy?
Hi,

In the function _gcry_ac_key_destroy, Is there a reason that:
gcry_free(key->data->data) is omitted?

Furthermore, for each element in key->data->data, shouldn't there also
be a gcry_free(key->data->data[i].name)?

Finally, is it reasonable to replace the if(key->data) block with
gcry_ac_data_destroy(key->data)?

I ask because I am using the ac library for encrypting messages and I
need to make sure all memory leaks are plugged.
According to valgrind there is a memory leak tied to memory allocated
in gcry_ac_key_init, and when I place the above two lines in
the destruction function, it fixes it.

-manu

ac.c (~ line 1683)
void
_gcry_ac_key_destroy (gcry_ac_key_t key)
{
unsigned int i;

if (key)
{
if (key->data)
{
for (i = 0; i < key->data->data_n; i++) {
if (key->data->data[i].mpi != NULL) {
gcry_mpi_release (key->data->data[i].mpi);
//gcry_free(key->data->data[i].name); *should
insert this*?
}
}
//gcry_free(key->data->data); *should insert this*?
gcry_free (key->data);
}
gcry_free (key);
}
}

_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
Re: Memory leak in gcry_ac_key_destroy? [ In reply to ]
On Sun, 20 Jul 2008 00:21, mastermanu2004@gmail.com said:

> In the function _gcry_ac_key_destroy, Is there a reason that:
> gcry_free(key->data->data) is omitted?

The reason is that thare are some conceptual bugs in the ac interface:
The ownership of some memory objects are not always clear and thus it is
hard to free them at the right place. I have given up on fixing them.
This is one reasons for the deprecation of the ac interface.

> I ask because I am using the ac library for encrypting messages and I

If it is at all possible for you, you should migrate to the pk
interface.



Salam-Shalom,

Werner

--
Die Gedanken sind frei. Auschnahme regelt ein Bundeschgesetz.


_______________________________________________
Gcrypt-devel mailing list
Gcrypt-devel@gnupg.org
http://lists.gnupg.org/mailman/listinfo/gcrypt-devel