Skip to content

Commit

Permalink
Actually use number correctly casted from double to int as index
Browse files Browse the repository at this point in the history
The code was using (int)jv_number_value(k) instead of (int)didx.

follow-up from 0e067ef

Useless assignments to didx detected by clang-tidy.
  • Loading branch information
emanuele6 authored and nicowilliams committed Sep 28, 2023
1 parent 8206bc8 commit 6b5a18f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/jv_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6b5a18f

Please # to comment.