Mercurial > hg > th-libs
changeset 706:d289fae3c1a8
Oops, forgot to free elemlens in th_join_string_elems() in no-error case. Ugh.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 27 Apr 2020 00:16:40 +0300 |
parents | dee28d507da7 |
children | 57d30f49fe1e |
files | th_string.c |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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; }