Re: PATCH: anti memleak part 1



On 2001.10.18 10:55 Ali Akcaagac wrote:
> jo, subject says everything. please REVIEW the patch before
> applying to CVS.. part 2 soon to follow..
> 
> hey manu, interested in nailing memleaks down in libbalsa ?
...
> diff -ruN balsa-cvs/src/balsa-app.c balsa/src/balsa-app.c
> --- balsa-cvs/src/balsa-app.c	Thu Oct 18 16:38:15 2001
> +++ balsa/src/balsa-app.c	Thu Oct 18 16:51:17 2001
...
> @@ -188,14 +186,14 @@
>  static int
>  tlsinteract (char *buf, int buflen, int rwflag, void *arg)
>  {
> -  char *pw;
>    int len;
> 
> -  pw = balsa_app.smtp_certificate_passphrase;
> -  len = strlen (pw);
> +  len = strlen (balsa_app.smtp_certificate_passphrase);
> +
>    if (len + 1 > buflen)
>      return 0;
> -  strcpy (buf, pw);
> +
> +  buf = balsa_app.smtp_certificate_passphrase;
>    return len;
>  }
>  #endif

I don't think this one works.  `tlsinteract' would have to be called 
with `char **buf_p' instead of `char *buf', and then  you could end 
with `*buf_p = balsa_app.smtp_certificate_passphrase;'  In your 
suggested code, `buf' is changed on the stack, but nothing is changed 
in the caller's frame.

If you *really* wanted to get rid of `char *pw', you could finish up 
with `strcpy (buf, balsa_app.smtp_certificate_passphrase);'



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]