[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-4-g3e0
From: |
Ludovic Courtès |
Subject: |
Re: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-4-g3e05fc0 |
Date: |
Mon, 21 Feb 2011 21:50:11 +0100 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (gnu/linux) |
Hi!
"Andy Wingo" <address@hidden> writes:
> fix a couple leaks in ports.c. thanks valgrind!
>
> * libguile/ports.c (scm_i_remove_port): Fix a case in which ports
> explictly closed via close-port would leak their iconv_t data.
> (scm_set_port_encoding_x): scm_i_set_port_encoding_x strdups its
> argument, so we need to free the locale encoding of the incoming str.
Good catch!
> --- a/libguile/ports.c
> +++ b/libguile/ports.c
> @@ -661,6 +661,19 @@ scm_i_remove_port (SCM port)
> scm_port_non_buffer (p);
> p->putback_buf = NULL;
> p->putback_buf_size = 0;
> +
> + if (p->input_cd != (iconv_t) -1)
> + {
> + iconv_close (p->input_cd);
> + p->input_cd = (iconv_t) -1;
> + }
> +
> + if (p->output_cd != (iconv_t) -1)
> + {
> + iconv_close (p->output_cd);
> + p->output_cd = (iconv_t) -1;
> + }
> +
I don’t think this is needed: each port has a finalizer,
‘finalize_port’, which normally takes care of this, eventually.
Thanks,
Ludo’.
- Re: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.0-4-g3e05fc0,
Ludovic Courtès <=