aboutsummaryrefslogtreecommitdiffstats
path: root/src/comp.c
diff options
context:
space:
mode:
authorAndrea Corallo2021-02-16 21:49:32 +0100
committerAndrea Corallo2021-02-16 21:49:32 +0100
commit72e4a22391bcb5d4ef484eb1dd32a614dbdbfd7b (patch)
tree57d7a53244da4b1543a1ab4f77be983cc42ade6c /src/comp.c
parent543e6e664cf1f25fd7df04e75ffb582f5c7feab4 (diff)
downloademacs-72e4a22391bcb5d4ef484eb1dd32a614dbdbfd7b.tar.gz
emacs-72e4a22391bcb5d4ef484eb1dd32a614dbdbfd7b.zip
* Better long range check
* src/comp.c (emit_rvalue_from_emacs_uint) (emit_rvalue_from_emacs_int, emit_rvalue_from_lisp_word_tag) (emit_rvalue_from_lisp_word): Better long range check.
Diffstat (limited to 'src/comp.c')
-rw-r--r--src/comp.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/comp.c b/src/comp.c
index 0ab7ab600a4..ce9c387568a 100644
--- a/src/comp.c
+++ b/src/comp.c
@@ -1166,7 +1166,7 @@ emit_rvalue_from_unsigned_long_long (gcc_jit_type *type, unsigned long long n)
1166static gcc_jit_rvalue * 1166static gcc_jit_rvalue *
1167emit_rvalue_from_emacs_uint (EMACS_UINT val) 1167emit_rvalue_from_emacs_uint (EMACS_UINT val)
1168{ 1168{
1169 if (val != (long) val) 1169 if (val > LONG_MAX || val < LONG_MIN)
1170 return emit_rvalue_from_unsigned_long_long (comp.emacs_uint_type, val); 1170 return emit_rvalue_from_unsigned_long_long (comp.emacs_uint_type, val);
1171 else 1171 else
1172 return gcc_jit_context_new_rvalue_from_long (comp.ctxt, 1172 return gcc_jit_context_new_rvalue_from_long (comp.ctxt,
@@ -1177,7 +1177,7 @@ emit_rvalue_from_emacs_uint (EMACS_UINT val)
1177static gcc_jit_rvalue * 1177static gcc_jit_rvalue *
1178emit_rvalue_from_emacs_int (EMACS_INT val) 1178emit_rvalue_from_emacs_int (EMACS_INT val)
1179{ 1179{
1180 if (val != (long) val) 1180 if (val > LONG_MAX || val < LONG_MIN)
1181 return emit_rvalue_from_long_long (comp.emacs_int_type, val); 1181 return emit_rvalue_from_long_long (comp.emacs_int_type, val);
1182 else 1182 else
1183 return gcc_jit_context_new_rvalue_from_long (comp.ctxt, 1183 return gcc_jit_context_new_rvalue_from_long (comp.ctxt,
@@ -1187,7 +1187,7 @@ emit_rvalue_from_emacs_int (EMACS_INT val)
1187static gcc_jit_rvalue * 1187static gcc_jit_rvalue *
1188emit_rvalue_from_lisp_word_tag (Lisp_Word_tag val) 1188emit_rvalue_from_lisp_word_tag (Lisp_Word_tag val)
1189{ 1189{
1190 if (val != (long) val) 1190 if (val > LONG_MAX || val < LONG_MIN)
1191 return emit_rvalue_from_unsigned_long_long (comp.lisp_word_tag_type, val); 1191 return emit_rvalue_from_unsigned_long_long (comp.lisp_word_tag_type, val);
1192 else 1192 else
1193 return gcc_jit_context_new_rvalue_from_long (comp.ctxt, 1193 return gcc_jit_context_new_rvalue_from_long (comp.ctxt,
@@ -1203,7 +1203,7 @@ emit_rvalue_from_lisp_word (Lisp_Word val)
1203 comp.lisp_word_type, 1203 comp.lisp_word_type,
1204 val); 1204 val);
1205#else 1205#else
1206 if (val != (long) val) 1206 if (val > LONG_MAX || val < LONG_MIN)
1207 return emit_rvalue_from_unsigned_long_long (comp.lisp_word_type, val); 1207 return emit_rvalue_from_unsigned_long_long (comp.lisp_word_type, val);
1208 else 1208 else
1209 return gcc_jit_context_new_rvalue_from_long (comp.ctxt, 1209 return gcc_jit_context_new_rvalue_from_long (comp.ctxt,