# HG changeset patch # User Matti Hamalainen # Date 1587935800 -10800 # Node ID d289fae3c1a87c5c079544a4b1ce145364306854 # Parent dee28d507da7ae079fab4d0ca2180326fc1d7ac3 Oops, forgot to free elemlens in th_join_string_elems() in no-error case. Ugh. diff -r dee28d507da7 -r d289fae3c1a8 th_string.c --- a/th_string.c Mon Apr 27 00:11:28 2020 +0300 +++ b/th_string.c Mon Apr 27 00:16:40 2020 +0300 @@ -659,6 +659,7 @@ int th_join_string_elems(th_char_t **str, const th_strelems_t *ctx, const th_char_t *sep) { size_t len, n, offs, seplen, *elemlens; + int res = THERR_OK; if (str == NULL || ctx == NULL || sep == NULL) return THERR_NULLPTR; @@ -677,8 +678,8 @@ if ((*str = th_malloc(len)) == NULL) { - th_free(elemlens); - return THERR_MALLOC; + res = THERR_MALLOC; + goto out; } for (offs = n = 0; n < ctx->nelems; n++) @@ -695,6 +696,8 @@ (*str)[offs] = 0; +out: + th_free(elemlens); return THERR_OK; }