[Dovecot] PATCH: mysql authentication

Timo Sirainen tss at iki.fi
Fri Oct 3 21:11:19 EEST 2003


On Fri, 2003-10-03 at 19:54, Matthew Reimer wrote:
> Here's another patch. This one isn't much different from the last patch, 
> except it tries a little harder to make sure that the required fields 
> are returned by the query (like the pgsql module does).

Thanks. I'll look it again later :)

> One question about how t_strdup works. How and who should memory 
> returned by t_strdup be freed? My patch has a function my_get_str() 
> which returns the value of t_strdup, and then I do this:
> 
>      user.uid = atoi(my_get_str(res, row, "uid")); /* XXX leak */
>      user.gid = atoi(my_get_str(res, row, "gid")); /* XXX leak */
> 
> Will this result in a memory leak?

No.

Memory allocated by t_*() functions are freed "later". There's first
t_push(), then you allocate memory, then t_pop() frees it all. So they
never leak memory, but they could allocate more memory than necessary if
called inside loop. That can be fixed by adding t_push/t_pop calls
there.




More information about the dovecot mailing list