mirror of https://github.com/getdnsapi/getdns.git
Yay! Segfault resolved. + another little mem leak
So the segfault was on destroying the req->extensions dict. This dict should have been initialized by dns_req_new, when it copied the extensions dict that it had as an argument. Though, the argument could have been NULL in which case nothing is copied. To overcome, I've altered dnsget_dict_copy to initialize the target with NULL when the src was NULL.
This commit is contained in:
parent
74fcc3c81b
commit
3827db1ad4
69
src/dict.c
69
src/dict.c
|
@ -234,48 +234,43 @@ getdns_dict_create()
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_dict_copy(struct getdns_dict * srcdict, struct getdns_dict ** dstdict)
|
getdns_dict_copy(struct getdns_dict * srcdict, struct getdns_dict ** dstdict)
|
||||||
{
|
{
|
||||||
getdns_return_t retval = GETDNS_RETURN_NO_SUCH_DICT_NAME;
|
|
||||||
struct getdns_dict_item *item;
|
struct getdns_dict_item *item;
|
||||||
char *key;
|
char *key;
|
||||||
|
|
||||||
if (srcdict != NULL && dstdict != NULL) {
|
if (dstdict == NULL)
|
||||||
*dstdict = getdns_dict_create();
|
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
|
||||||
|
if (srcdict == NULL) {
|
||||||
LDNS_RBTREE_FOR(item, struct getdns_dict_item *,
|
*dstdict = NULL;
|
||||||
&(srcdict->root))
|
return GETDNS_RETURN_GOOD;
|
||||||
{
|
|
||||||
key = (char *) item->node.key;
|
|
||||||
switch (item->dtype) {
|
|
||||||
case t_bindata:
|
|
||||||
getdns_dict_set_bindata(*dstdict, key,
|
|
||||||
item->data.bindata);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case t_dict:
|
|
||||||
getdns_dict_set_dict(*dstdict, key,
|
|
||||||
item->data.dict);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case t_int:
|
|
||||||
getdns_dict_set_int(*dstdict, key,
|
|
||||||
item->data.n);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case t_list:
|
|
||||||
getdns_dict_set_list(*dstdict, key,
|
|
||||||
item->data.list);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case t_invalid:
|
|
||||||
default:
|
|
||||||
// TODO: this is a fault of some kind, for now ignore it
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
retval = GETDNS_RETURN_GOOD;
|
|
||||||
}
|
}
|
||||||
|
*dstdict = getdns_dict_create();
|
||||||
|
LDNS_RBTREE_FOR(item, struct getdns_dict_item *, &(srcdict->root)) {
|
||||||
|
key = (char *) item->node.key;
|
||||||
|
switch (item->dtype) {
|
||||||
|
case t_bindata:
|
||||||
|
getdns_dict_set_bindata(*dstdict, key,
|
||||||
|
item->data.bindata);
|
||||||
|
break;
|
||||||
|
|
||||||
return retval;
|
case t_dict:
|
||||||
|
getdns_dict_set_dict(*dstdict, key, item->data.dict);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case t_int:
|
||||||
|
getdns_dict_set_int(*dstdict, key, item->data.n);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case t_list:
|
||||||
|
getdns_dict_set_list(*dstdict, key, item->data.list);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case t_invalid:
|
||||||
|
default:
|
||||||
|
// TODO: this is a fault of some kind, for now ignore it
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GETDNS_RETURN_GOOD;
|
||||||
} /* getdns_dict_copy */
|
} /* getdns_dict_copy */
|
||||||
|
|
||||||
/*---------------------------------------- getdns_dict_item_free */
|
/*---------------------------------------- getdns_dict_item_free */
|
||||||
|
|
|
@ -44,6 +44,7 @@ this_callbackfn(struct getdns_context_t *this_context,
|
||||||
char *res = getdns_pretty_print_dict(this_response);
|
char *res = getdns_pretty_print_dict(this_response);
|
||||||
fprintf(stdout, "%s", res);
|
fprintf(stdout, "%s", res);
|
||||||
getdns_dict_destroy(this_response);
|
getdns_dict_destroy(this_response);
|
||||||
|
free(res);
|
||||||
|
|
||||||
} else if (this_callback_type == GETDNS_CALLBACK_CANCEL)
|
} else if (this_callback_type == GETDNS_CALLBACK_CANCEL)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
|
Loading…
Reference in New Issue