Sun, 02 Jul 2023 11:06:14 +0200
fix crash in merge_tags() when one list was NULL
dav/tags.c | file | annotate | diff | comparison | revisions |
--- a/dav/tags.c Sun Jul 02 11:03:37 2023 +0200 +++ b/dav/tags.c Sun Jul 02 11:06:14 2023 +0200 @@ -428,25 +428,30 @@ new_tags->simple_destructor = (cx_destructor_func)free_dav_tag; // add all local tags - CxIterator iter = cxListIterator(tags1); - cx_foreach(DavTag*, t, iter) { - cxMapPut(tag_map, cx_hash_key_str(t->name), t); - DavTag *newt = calloc(1, sizeof(DavTag)); - newt->color = t->color ? strdup(t->color) : NULL; - newt->name = strdup(t->name); - cxListAdd(new_tags, newt); - } - // check if a remote tag is already in the map - // and if not add it to the new taglist - iter = cxListIterator(tags2); - cx_foreach(DavTag*, t, iter) { - if(!cxMapGet(tag_map, cx_hash_key_str(t->name))) { + if(tags1) { + CxIterator iter = cxListIterator(tags1); + cx_foreach(DavTag*, t, iter) { + cxMapPut(tag_map, cx_hash_key_str(t->name), t); DavTag *newt = calloc(1, sizeof(DavTag)); newt->color = t->color ? strdup(t->color) : NULL; newt->name = strdup(t->name); cxListAdd(new_tags, newt); } } + + // check if a remote tag is already in the map + // and if not add it to the new taglist + if(tags2) { + CxIterator iter = cxListIterator(tags2); + cx_foreach(DavTag*, t, iter) { + if(!cxMapGet(tag_map, cx_hash_key_str(t->name))) { + DavTag *newt = calloc(1, sizeof(DavTag)); + newt->color = t->color ? strdup(t->color) : NULL; + newt->name = strdup(t->name); + cxListAdd(new_tags, newt); + } + } + } cxMapDestroy(tag_map);