Hi,

I trust you, but I have checked the code :)

you are right, the at_command_create may fail (on allocation error
from g_try_new0) and in this case it doesn't call the g_free.

However I have to say that the code leaks alot: overall the construct
is used 237 times, and only 98 times the g_free is called.
That said, according to Denis nowadays we don't use g_try_new0 because
the allocation won't fail, so we are unlikely to see it in action.

I add the g_free :D

Regards,
Giacinto

On Fri, Oct 12, 2018 at 6:31 PM Jonas Bonn <[email protected]> wrote:
>
>
> On 12/10/18 18:23, Giacinto Cifelli wrote:
> > actually:
> >
> >>> +
> >>> +     if (g_at_chat_send(cbd->ldd->chat, buf, NULL,
> >>> +                     at_lte_set_auth_cb, cbd, g_free) > 0)
> >>> +             return;
> >>> +
> >> Here you'll leak cbd again.
> > here there is a g_free in the call. Also in case of failure the g_free
> > is executed, I think (also because it is the same construct as
> > everywhere else).
> > Or not?
>
> If g_at_chat_send returns 0, g_free() won't be called so you need to
> free the data yourself.  That should be the construct used elsewhere so
> if you see it done differently your seeing bugs (probably).
>
> /Jonas
>
_______________________________________________
ofono mailing list
[email protected]
https://lists.ofono.org/mailman/listinfo/ofono

Reply via email to