Skip to content

Commit

Permalink
Fix multiple string multiplication
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny authored and wtlangford committed May 26, 2020
1 parent 15fa1de commit 9163e09
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9163e09

Please sign in to comment.