diff --git a/common/living.c b/common/living.c index 884c4b1..3917060 100644 --- a/common/living.c +++ b/common/living.c @@ -1184,7 +1184,9 @@ void fix_object(object *op) { if (tmp->slaying!=NULL) { if (op->slaying != NULL) - op->slaying = join_strings(op->slaying, tmp->slaying, ","); + sstring joined_str = join_strings(op->slaying, tmp->slaying, ","); + free_string(op->slaying); + op->slaying = joined_str; else add_refcount(op->slaying = tmp->slaying); } @@ -1236,7 +1238,9 @@ void fix_object(object *op) { weapon_speed=0; if (tmp->slaying!=NULL) { if (op->slaying != NULL) - op->slaying = join_strings(op->slaying, tmp->slaying, ","); + sstring joined_str = join_strings(op->slaying, tmp->slaying, ","); + free_string(op->slaying); + op->slaying = joined_str; else add_refcount(op->slaying = tmp->slaying); } @@ -1279,7 +1283,9 @@ void fix_object(object *op) { max=ARMOUR_SPEED(tmp)/10.0; if (tmp->slaying!=NULL) { if (op->slaying != NULL) - op->slaying = join_strings(op->slaying, tmp->slaying, ","); + sstring joined_str = join_strings(op->slaying, tmp->slaying, ","); + free_string(op->slaying); + op->slaying = joined_str; else add_refcount(op->slaying = tmp->slaying); } diff --git a/common/shstr.c b/common/shstr.c index 72687f1..5c316eb 100644 --- a/common/shstr.c +++ b/common/shstr.c @@ -237,10 +237,8 @@ sstring join_strings(sstring target_str, sstring source_str, const char *separat /* create shared string from buffer */ ss = add_string(buf); - /* free our buffer and our shared string references */ + /* free our buffer */ free(buf); - free_string(target_str); - free_string(source_str); return ss; }