Commit 5feabdcb authored by rswindell's avatar rswindell
Browse files

Avoid some NULL dereferences when passed NULL str_list_t args.

parent 08c0934b
......@@ -207,6 +207,8 @@ char* strListReplace(const str_list_t list, size_t index, const char* str)
size_t strListModifyEach(const str_list_t list, char*(modify(size_t, char*, void*)), void* cbdata)
{
size_t i;
if(list == NULL)
return 0;
for(i = 0; list[i] != NULL; i++) {
char* str = modify(i, list[i], cbdata);
if(str == NULL || str == list[i]) // Same old pointer (or NULL), no modification
......@@ -269,7 +271,7 @@ size_t strListAppendList(str_list_t* list, const str_list_t add_list)
size_t count;
count=strListCount(*list);
for(i=0; add_list[i]!=NULL; i++)
for(i=0; add_list != NULL && add_list[i] != NULL; i++)
strListAppend(list,add_list[i],count++);
return(count);
......@@ -318,6 +320,9 @@ size_t strListInsertList(str_list_t* list, const str_list_t add_list, size_t ind
{
size_t i;
if(add_list == NULL)
return 0;
for(i=0; add_list[i]!=NULL; i++)
if(strListInsert(list,add_list[i],index++)==NULL)
break;
......@@ -398,6 +403,9 @@ size_t strListMerge(str_list_t* list, str_list_t add_list)
size_t i;
size_t count;
if(add_list == NULL)
return 0;
count=strListCount(*list);
for(i=0; add_list[i]!=NULL; i++)
str_list_append(list,add_list[i],count++);
......@@ -690,7 +698,7 @@ char* strListAppendBlock(char* block, str_list_t list)
if((block_len=strListBlockLength(block))!=0)
block_len--; /* Over-write existing NULL terminator */
for(i=0; list[i]!=NULL; i++) {
for(i=0; list != NULL && list[i] != NULL; i++) {
str_len=strlen(list[i]);
if(str_len==0)
continue; /* can't include empty strings in block */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment