diff --git a/src/list.c b/src/list.c index fbce8b3f..5cf7d24e 100644 --- a/src/list.c +++ b/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; diff --git a/src/test/Makefile.in b/src/test/Makefile.in index b16ca313..f5583513 100644 --- a/src/test/Makefile.in +++ b/src/test/Makefile.in @@ -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