From d5da21ae85ab42ba450ad4de391ad29db40bcc60 Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Fri, 17 Mar 2006 08:49:22 +0000 Subject: [PATCH] warn of null keys in ll --- src/ll.c | 10 ++++++++++ src/ll.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/ll.c b/src/ll.c index 8dd01932..b14153d3 100644 --- a/src/ll.c +++ b/src/ll.c @@ -125,6 +125,11 @@ int ll_add_ll(LL *pl, char *key, LL *pnew) { int _ll_add_item(LL *pl, char *key, void* vpval, int ival, int type) { LL_ITEM *pli; + if(!key) { + DPRINTF(E_LOG,L_MISC,"_ll_add_item: passed null key\n"); + return LL_E_BADPARAM; + } + if(pl->flags & LL_FLAG_NODUPS) { if(ll_fetch_item(pl,key)) return LL_E_DUP; @@ -146,6 +151,11 @@ int _ll_add_item(LL *pl, char *key, void* vpval, int ival, int type) { pli->value.as_ll = (LL *)vpval; break; case LL_TYPE_STRING: + if(!vpval) { + DPRINTF(E_LOG,L_MISC,"_ll_add_item: passed null value\n"); + free(pli); + return LL_E_BADPARAM; + } pli->value.as_string = strdup((char*)vpval); break; default: diff --git a/src/ll.h b/src/ll.h index e7771459..83909187 100644 --- a/src/ll.h +++ b/src/ll.h @@ -31,6 +31,7 @@ #define LL_E_MALLOC 1 #define LL_E_NOKEY 2 #define LL_E_DUP 3 +#define LL_E_BADPARAM 4 #define LL_FLAG_HONORCASE 1 /** Make keys case sensitive */ #define LL_FLAG_HEADINSERT 2 /** Insert at head, rather than tail */