diff --git a/src/err.c b/src/err.c index 366c34d7..8c6262e5 100644 --- a/src/err.c +++ b/src/err.c @@ -183,11 +183,14 @@ void err_setdest(char *cvalue, int destination) { extern int err_setdebugmask(char *list) { unsigned int rack; char *token, *str, *last; + char *tmpstr; int index; err_debugmask=0x80000000; /* always log L_MISC! */ - str=list; - + str=tmpstr=strdup(list); + if(!str) + return 0; + while(1) { token=strtok_r(str,",",&last); str=NULL; @@ -203,6 +206,7 @@ extern int err_setdebugmask(char *list) { if(!err_categorylist[index]) { DPRINTF(E_LOG,L_MISC,"Unknown module: %s\n",token); + free(tmpstr); return 1; } else { DPRINTF(E_DBG,L_MISC,"Adding module %s to debug list (0x%08x)\n",token,rack); @@ -212,6 +216,7 @@ extern int err_setdebugmask(char *list) { } DPRINTF(E_INF,L_MISC,"Debug mask is 0x%08x\n",err_debugmask); + free(tmpstr); return 0; }