[getdns-api] Memory leaks in getdns_context_get_api_information()
Willem Toorop
willem at nlnetlabs.nl
Fri Feb 26 11:28:16 UTC 2016
Thank you Robert!
Good catch. I've committed a fix:
https://github.com/getdnsapi/getdns/commit/6fd05675aa96337b164bd7e9e480cc30f7eb9897
Best regards,
-- Willem
Op 25-02-16 om 15:37 schreef Robert Groenenberg:
> Hi,
>
> While testing my application, which uses getdns 0.9.0, I found two small
> memory leaks related to getdns_context_get_api_information(), but
> probably I'm missing something...
>
> I destroy the returned dict from getdns_context_get_api_information(),
> but according to valgrind there are two leaks. The first
> (context.c:2948) refers to the dns transport list, the second to the
> namespaces list. Apparently these are not freed as part of the
> getdns_dict_destroy().
>
> Am I forgetting to destroy something?
>
> res = getdns_context_create(&ctxt, 0);
> if (res == GETDNS_RETURN_GOOD)
> {
> dict = *getdns_context_get_api_information*(ctxt);
> if (dict != NULL)
> {
> if ((res = *getdns_dict_get_bindata*(dict,
> "/version_string",
> &version)) ==
> GETDNS_RETURN_GOOD))
> {
> trace_mod(TRACE_INFO,
> "Using getdns library version %.*s",
> version->size, version->data);
> }
> *getdns_dict_destroy*(dict);
> dict = NULL;
> }
> else
> {
> trace_mod(BF_TRACE_ERROR,
> "Failed to initialise getdns library: %s (%d)",
> getdns_get_errorstr_by_id(res), res);
> retval = FAILURE;
> }
>
> /* Cleanup */
> *getdns_context_destroy*(ctxt);
> ctxt = NULL;
> }
>
>> ==11484== 216 (56 direct, 160 indirect) bytes in 1 blocks are
>> definitely lost in loss record 637 of 686
>> ==11484== at 0x4A08455: malloc (vg_replace_malloc.c:299)
>> ==11484== by 0x224B6F86:
>> getdns_list_create_with_extended_memory_functions (list.c:380)
>> ==11484== by 0x224C5F15: _get_context_settings (context.c:2948)
>> ==11484== by 0x224C5F15: *getdns_context_get_api_information
>> *(context.c:2986)
>> ==11484== by 0x22191724: mf_am_init (enum_init.c:136)
>> ==11484== by 0x4366F0: mf_am_process_init (mf_am.c:837)
>> ==11484== by 0x43B23A: mf_core_init (mf_core.c:487)
>> ==11484== by 0x40FB31: main (mf_main.c:422)
>> ==11484==
>> ==11484== 216 (56 direct, 160 indirect) bytes in 1 blocks are
>> definitely lost in loss record 638 of 686
>> ==11484== at 0x4A08455: malloc (vg_replace_malloc.c:299)
>> ==11484== by 0x224B6F86:
>> getdns_list_create_with_extended_memory_functions (list.c:380)
>> ==11484== by 0x224C5DE2: _get_context_settings (context.c:2960)
>> ==11484== by 0x224C5DE2: *getdns_context_get_api_information*
>> (context.c:2986)
>> ==11484== by 0x22191724: mf_am_init (enum_init.c:136)
>> ==11484== by 0x4366F0: mf_am_process_init (mf_am.c:837)
>> ==11484== by 0x43B23A: mf_core_init (mf_core.c:487)
>> ==11484== by 0x40FB31: main (mf_main.c:422)
>
> Thanks,
> Robert
>
>
> _______________________________________________
> spec mailing list
> spec at getdnsapi.net
>
More information about the spec
mailing list