From: Marcus Brinkmann Date: Sun, 11 Nov 2001 18:54:57 +0000 (+0000) Subject: 2001-11-11 Marcus Brinkmann X-Git-Tag: gpgme-1.2.0@1385~1286 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e5d088e717ccd8b2a4190d1532cb95a1f3cecdf1;p=gpgme.git 2001-11-11 Marcus Brinkmann * rungpg.c (_gpgme_gpg_release): Release GPG->cmd.cb_data. Release all members of the list GPG->arglist. Reported by Michael Schmidt . --- diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index 8e932b9..664bab7 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,3 +1,9 @@ +2001-11-11 Marcus Brinkmann + + * rungpg.c (_gpgme_gpg_release): Release GPG->cmd.cb_data. + Release all members of the list GPG->arglist. + Reported by Michael Schmidt . + 2001-11-02 Marcus Brinkmann * rungpg.c (pipemode_copy): Change type of NBYTES to size_t. diff --git a/trunk/gpgme/rungpg.c b/trunk/gpgme/rungpg.c index cbc727c..60cfa22 100644 --- a/trunk/gpgme/rungpg.c +++ b/trunk/gpgme/rungpg.c @@ -244,45 +244,56 @@ _gpgme_gpg_new ( GpgObject *r_gpg ) void -_gpgme_gpg_release ( GpgObject gpg ) +_gpgme_gpg_release (GpgObject gpg) { - if ( !gpg ) - return; - xfree (gpg->status.buffer); - xfree (gpg->colon.buffer); - if ( gpg->argv ) - free_argv (gpg->argv); - xfree (gpg->cmd.keyword); - - if (gpg->pid != -1) - _gpgme_remove_proc_from_wait_queue ( gpg->pid ); - if (gpg->status.fd[0] != -1 ) - _gpgme_io_close (gpg->status.fd[0]); - if (gpg->status.fd[1] != -1 ) - _gpgme_io_close (gpg->status.fd[1]); - if (gpg->colon.fd[0] != -1 ) - _gpgme_io_close (gpg->colon.fd[0]); - if (gpg->colon.fd[1] != -1 ) - _gpgme_io_close (gpg->colon.fd[1]); - free_fd_data_map (gpg->fd_data_map); - if (gpg->running) { - int pid = gpg->pid; - struct reap_s *r; - - /* resuse the memory, so that we don't need to allocate another - * mem block and have to handle errors */ - assert (sizeof *r < sizeof *gpg ); - r = (void*)gpg; - memset (r, 0, sizeof *r); - r->pid = pid; - r->entered = time (NULL); - LOCK(reap_list_lock); - r->next = reap_list; - reap_list = r; - UNLOCK(reap_list_lock); + if (!gpg) + return; + + while (gpg->arglist) + { + struct arg_and_data_s *next = gpg->arglist->next; + + xfree (gpg->arglist); + gpg->arglist = next; } - else - xfree (gpg); + + xfree (gpg->status.buffer); + xfree (gpg->colon.buffer); + if (gpg->argv) + free_argv (gpg->argv); + xfree (gpg->cmd.cb_data); + xfree (gpg->cmd.keyword); + + if (gpg->pid != -1) + _gpgme_remove_proc_from_wait_queue (gpg->pid); + if (gpg->status.fd[0] != -1) + _gpgme_io_close (gpg->status.fd[0]); + if (gpg->status.fd[1] != -1) + _gpgme_io_close (gpg->status.fd[1]); + if (gpg->colon.fd[0] != -1) + _gpgme_io_close (gpg->colon.fd[0]); + if (gpg->colon.fd[1] != -1) + _gpgme_io_close (gpg->colon.fd[1]); + free_fd_data_map (gpg->fd_data_map); + if (gpg->running) + { + int pid = gpg->pid; + struct reap_s *r; + + /* Reuse the memory, so that we don't need to allocate another + memory block and to handle errors. */ + assert (sizeof *r < sizeof *gpg); + r = (void*)gpg; + memset (r, 0, sizeof *r); + r->pid = pid; + r->entered = time (NULL); + LOCK(reap_list_lock); + r->next = reap_list; + reap_list = r; + UNLOCK(reap_list_lock); + } + else + xfree (gpg); }