# HG changeset patch # User Olaf Wintermann # Date 1688288774 -7200 # Node ID 24b317ce5ca91463e299fdcee422709f129076ec # Parent eb495f3d40651a32cc83bee28f0cce9f108842fd fix crash in merge_tags() when one list was NULL diff -r eb495f3d4065 -r 24b317ce5ca9 dav/tags.c --- 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);