Fix multiple string multiplication

This commit is contained in:
itchyny authored and William Langford committed 2020-05-26 12:30:27 -04:00
1 parent 15fa1dec99
commit 9163e09605
1 file changed
+3 -2
+3 -2
View File
@@ -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;