Actually use number correctly casted from double to int as index

The code was using (int)jv_number_value(k) instead of (int)didx.

follow-up from 0e067ef936

Useless assignments to didx detected by clang-tidy.
This commit is contained in:
Emanuele Torre authored and Nico Williams committed 2023-09-27 22:54:23 -05:00
1 parent 8206bc8fd2
commit 6b5a18f036
1 file changed
+1 -1
+1 -1
View File
@@ -95,7 +95,7 @@ jv jv_get(jv t, jv k) {
} else {
if (didx < INT_MIN) didx = INT_MIN;
if (didx > INT_MAX) didx = INT_MAX;
int idx = (int)jv_number_value(k);
int idx = (int)didx;
if (idx < 0)
idx += jv_array_length(jv_copy(t));
v = jv_array_get(t, idx);