diff options
author | William Langford <wlangfor@gmail.com> | 2015-03-23 22:11:55 -0400 |
---|---|---|
committer | William Langford <wlangfor@gmail.com> | 2015-03-23 22:11:55 -0400 |
commit | 0f7759f83106098312224e9cabc5464b8e19a3d0 (patch) | |
tree | f32c2f8b0032e37160bb33a51abe357d292761e4 /builtin.c | |
parent | ccfba00178ff972f4d1ee5e750b79218e380efa1 (diff) |
Fix #735
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -218,6 +218,9 @@ static jv f_divide(jq_state *jq, jv input, jv a, jv b) { static jv f_mod(jq_state *jq, jv input, jv a, jv b) { jv_free(input); if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) { + if ((intmax_t)jv_number_value(b) == 0) { + return jv_invalid_with_msg(jv_string("Cannot mod by zero.")); + } return jv_number((intmax_t)jv_number_value(a) % (intmax_t)jv_number_value(b)); } else { return type_error2(a, b, "cannot be divided"); |