gpgme memory leak? What's wrong?
Marcus Brinkmann
marcus.brinkmann at ruhr-uni-bochum.de
Mon Mar 20 20:17:05 CET 2006
At Mon, 27 Feb 2006 19:41:45 +0300,
"Vladimir S. Petukhov" <vladimir at sycore.org> wrote:
> GpgmeCtx gpgme_ctx;
> gpgme_new (&gpgme_ctx);
> gpgme_set_textmode (gpgme_ctx, 1);
> gpgme_set_armor (gpgme_ctx, 1);
> gpgme_set_passphrase_cb (gpgme_ctx, &passphrase_cb, NULL);
> while (true) {
>
> gpgme_data_new_from_mem (&gpgme_data_in, "test", 5, 0);
> gpgme_data_new (&gpgme_data_out);
> gpgme_op_sign gpgme_data_out, GPGME_SIG_MODE_CLEAR);
> gpgme_data_release (gpgme_data_out);
> gpgme_data_release (gpgme_data_in);
> }
> gpgme_release (gpgme_ctx);
>
>
> .. sign mesage well, but allocate memory incrementally.
> What's wrong? (version 1.4.2)
The code you quoted is not valid C code. After fixing the syntactical
errors, I produced the below version, which runs fine without any
memory leaks.
If you give me a self-standing, compiling source code file, I can try
it out as well. You can also try running valgrind on your program.
gpgme_new (&gpgme_ctx);
gpgme_set_textmode (gpgme_ctx, 1);
gpgme_set_armor (gpgme_ctx, 1);
gpgme_set_passphrase_cb (gpgme_ctx, passphrase_cb, NULL);
while (1)
{
gpgme_data_new_from_mem (&gpgme_data_in, "test", 5, 0);
gpgme_data_new (&gpgme_data_out);
gpgme_op_sign (gpgme_ctx, gpgme_data_in, gpgme_data_out,
GPGME_SIG_MODE_CLEAR);
gpgme_data_release (gpgme_data_out);
gpgme_data_release (gpgme_data_in);
}
gpgme_release (gpgme_ctx);
return 0;
Thanks,
Marcus
More information about the Gnupg-devel
mailing list