mirror of https://github.com/getdnsapi/getdns.git
Check for answer on getdns_list_get methods
This commit is contained in:
parent
601b821c43
commit
1e9f716b6f
11
src/list.c
11
src/list.c
|
@ -58,6 +58,9 @@ getdns_list_get_data_type(struct getdns_list * list, size_t index,
|
|||
if (!list || index >= list->numinuse)
|
||||
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||
|
||||
if (!answer)
|
||||
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||
|
||||
*answer = list->items[index].dtype;
|
||||
return GETDNS_RETURN_GOOD;
|
||||
} /* getdns_list_get_data_type */
|
||||
|
@ -70,7 +73,7 @@ getdns_list_get_dict(struct getdns_list * list, size_t index,
|
|||
if (!list || index >= list->numinuse)
|
||||
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||
|
||||
if (list->items[index].dtype != t_dict)
|
||||
if (!answer || list->items[index].dtype != t_dict)
|
||||
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||
|
||||
*answer = list->items[index].data.dict;
|
||||
|
@ -86,7 +89,7 @@ getdns_list_get_list(struct getdns_list * list, size_t index,
|
|||
if (!list || index >= list->numinuse)
|
||||
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||
|
||||
if (list->items[index].dtype != t_list)
|
||||
if (!answer || list->items[index].dtype != t_list)
|
||||
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||
|
||||
*answer = list->items[index].data.list;
|
||||
|
@ -101,7 +104,7 @@ getdns_list_get_bindata(struct getdns_list * list, size_t index,
|
|||
if (!list || index >= list->numinuse)
|
||||
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||
|
||||
if (list->items[index].dtype != t_bindata)
|
||||
if (!answer || list->items[index].dtype != t_bindata)
|
||||
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||
|
||||
*answer = list->items[index].data.bindata;
|
||||
|
@ -115,7 +118,7 @@ getdns_list_get_int(struct getdns_list * list, size_t index, uint32_t * answer)
|
|||
if (!list || index >= list->numinuse)
|
||||
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||
|
||||
if (list->items[index].dtype != t_int)
|
||||
if (!answer || list->items[index].dtype != t_int)
|
||||
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||
|
||||
*answer = list->items[index].data.n;
|
||||
|
|
|
@ -19,7 +19,7 @@ CC=gcc
|
|||
CFLAGS=@CFLAGS@ -Wall -I$(srcdir)/ -I$(srcdir)/../ -I/usr/local/include -std=c99 $(cflags)
|
||||
LDFLAGS=@LDFLAGS@ -L. -L.. -L/usr/local/lib
|
||||
LDLIBS=-lgetdns @LIBS@
|
||||
PROGRAMS=tests_dict tests_list tests_stub_async tests_stub_sync
|
||||
PROGRAMS=tests_dict tests_list tests_stub_async tests_stub_sync tests_list_mu
|
||||
|
||||
.SUFFIXES: .c .o .a .lo .h
|
||||
|
||||
|
@ -36,6 +36,10 @@ tests_dict: tests_dict.o testmessages.o
|
|||
tests_list: tests_list.o testmessages.o
|
||||
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_list.o testmessages.o
|
||||
|
||||
tests_list_mu: tests_list_mu.o
|
||||
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -lcunit -o $@
|
||||
tests_list_mu.o
|
||||
|
||||
tests_stub_async: tests_stub_async.o testmessages.o
|
||||
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_stub_async.o testmessages.o
|
||||
|
||||
|
|
Loading…
Reference in New Issue