From: William Langford Date: Tue, 24 Mar 2015 02:11:55 +0000 (-0400) Subject: Fix #735 X-Git-Tag: jq-1.5rc2~132 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f7759f83106098312224e9cabc5464b8e19a3d0;p=jq Fix #735 --- diff --git a/builtin.c b/builtin.c index 99ce331..03c9081 100644 --- a/builtin.c +++ b/builtin.c @@ -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");