Index: common/lib/libprop/prop_string.c =================================================================== RCS file: /cvsroot/src/common/lib/libprop/prop_string.c,v retrieving revision 1.17 diff -u -p -r1.17 prop_string.c --- common/lib/libprop/prop_string.c 3 Aug 2022 21:13:46 -0000 1.17 +++ common/lib/libprop/prop_string.c 17 Nov 2023 17:44:02 -0000 @@ -247,12 +247,18 @@ _prop_string_instantiate(int const flags */ prop_object_retain(ops); _PROP_MUTEX_UNLOCK(_prop_string_tree_mutex); + if ((flags & PS_F_NOCOPY) == 0) { + _PROP_FREE(ps->ps_mutable, + M_PROP_STRING); + } _PROP_POOL_PUT(_prop_string_pool, ps); ps = ops; } else { _PROP_MUTEX_UNLOCK(_prop_string_tree_mutex); } } + } else if ((flags & PS_F_NOCOPY) == 0) { + _PROP_FREE(ps->ps_mutable, M_PROP_STRING); } return (ps); @@ -311,7 +317,6 @@ prop_string_create_cstring_nocopy(const prop_string_t __printflike(1, 2) prop_string_create_format(const char *fmt, ...) { - prop_string_t ps; char *str = NULL; int len; size_t nlen; @@ -335,11 +340,7 @@ prop_string_create_format(const char *fm vsnprintf(str, nlen, fmt, ap); va_end(ap); - ps = _prop_string_instantiate(0, str, (size_t)len); - if (ps == NULL) - _PROP_FREE(str, M_PROP_STRING); - - return (ps); + return _prop_string_instantiate(0, str, (size_t)len); } /* @@ -374,7 +375,6 @@ prop_string_create_nocopy(const char *st prop_string_t prop_string_copy(prop_string_t ops) { - prop_string_t ps; char *cp; if (! prop_object_is_string(ops)) @@ -391,11 +391,7 @@ prop_string_copy(prop_string_t ops) strcpy(cp, prop_string_contents(ops)); - ps = _prop_string_instantiate(PS_F_MUTABLE, cp, ops->ps_size); - if (ps == NULL) - _PROP_FREE(cp, M_PROP_STRING); - - return (ps); + return _prop_string_instantiate(PS_F_MUTABLE, cp, ops->ps_size); } _PROP_DEPRECATED(prop_string_copy_mutable, @@ -404,7 +400,6 @@ _PROP_DEPRECATED(prop_string_copy_mutabl prop_string_t prop_string_copy_mutable(prop_string_t ops) { - prop_string_t ps; char *cp; if (! prop_object_is_string(ops)) @@ -416,11 +411,7 @@ prop_string_copy_mutable(prop_string_t o strcpy(cp, prop_string_contents(ops)); - ps = _prop_string_instantiate(PS_F_MUTABLE, cp, ops->ps_size); - if (ps == NULL) - _PROP_FREE(cp, M_PROP_STRING); - - return (ps); + return _prop_string_instantiate(PS_F_MUTABLE, cp, ops->ps_size); } /* @@ -692,8 +683,6 @@ _prop_string_internalize(prop_stack_t st } string = _prop_string_instantiate(0, str, len); - if (string == NULL) - _PROP_FREE(str, M_PROP_STRING); *obj = string; return (true);