diff options
author | itchyny <itchyny@hatena.ne.jp> | 2020-05-08 14:22:25 +0900 |
---|---|---|
committer | William Langford <wlangfor@gmail.com> | 2020-05-26 12:30:27 -0400 |
commit | 9163e09605383a88f6e953d6cb5cc2aebe18c84f (patch) | |
tree | d580cd0089241528805e6ce7dbb89675a66a8ded | |
parent | 15fa1dec99f2a709dd6c3ee9791af4a9f72b4a83 (diff) |
Fix multiple string multiplication
-rw-r--r-- | src/builtin.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/builtin.c b/src/builtin.c index 8533d7e6..35645ea8 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -322,14 +322,15 @@ static jv f_multiply(jq_state *jq, jv input, jv a, jv b) { } int n; size_t alen = jv_string_length_bytes(jv_copy(str)); - jv res = str; + jv res = jv_copy(str); for (n = jv_number_value(num) - 1; n > 0; n--) res = jv_string_append_buf(res, jv_string_value(str), alen); + jv_free(str); jv_free(num); if (n < 0) { - jv_free(str); + jv_free(res); return jv_null(); } return res; |