warn of null keys in ll
This commit is contained in:
parent
779a139c9d
commit
d5da21ae85
10
src/ll.c
10
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) {
|
int _ll_add_item(LL *pl, char *key, void* vpval, int ival, int type) {
|
||||||
LL_ITEM *pli;
|
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(pl->flags & LL_FLAG_NODUPS) {
|
||||||
if(ll_fetch_item(pl,key))
|
if(ll_fetch_item(pl,key))
|
||||||
return LL_E_DUP;
|
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;
|
pli->value.as_ll = (LL *)vpval;
|
||||||
break;
|
break;
|
||||||
case LL_TYPE_STRING:
|
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);
|
pli->value.as_string = strdup((char*)vpval);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
1
src/ll.h
1
src/ll.h
|
@ -31,6 +31,7 @@
|
||||||
#define LL_E_MALLOC 1
|
#define LL_E_MALLOC 1
|
||||||
#define LL_E_NOKEY 2
|
#define LL_E_NOKEY 2
|
||||||
#define LL_E_DUP 3
|
#define LL_E_DUP 3
|
||||||
|
#define LL_E_BADPARAM 4
|
||||||
|
|
||||||
#define LL_FLAG_HONORCASE 1 /** Make keys case sensitive */
|
#define LL_FLAG_HONORCASE 1 /** Make keys case sensitive */
|
||||||
#define LL_FLAG_HEADINSERT 2 /** Insert at head, rather than tail */
|
#define LL_FLAG_HEADINSERT 2 /** Insert at head, rather than tail */
|
||||||
|
|
Loading…
Reference in New Issue