From 372d62d4e1738431d33c1318be1ee4305c74649d Mon Sep 17 00:00:00 2001 From: "David N. Welton" Date: Mon, 15 Dec 2014 17:53:09 +0100 Subject: Do not accept Nan and Infinity values Erlang does not accept these values, so we return an error in the C interface rather than letting them through to the Erlang VM, which rejects the message with a somewhat cryptic "bad external term". --- lib/erl_interface/src/encode/encode_double.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/erl_interface/src/encode') diff --git a/lib/erl_interface/src/encode/encode_double.c b/lib/erl_interface/src/encode/encode_double.c index 148a49f73a..a19a871eda 100644 --- a/lib/erl_interface/src/encode/encode_double.c +++ b/lib/erl_interface/src/encode/encode_double.c @@ -18,6 +18,9 @@ */ #include #include +#if defined(HAVE_ISFINITE) +#include +#endif #include "eidef.h" #include "eiext.h" #include "putget.h" @@ -27,6 +30,15 @@ int ei_encode_double(char *buf, int *index, double p) char *s = buf + *index; char *s0 = s; + /* Erlang does not handle Inf and NaN, so we return an error rather + * than letting the Erlang VM complain about a bad external + * term. */ +#if defined(HAVE_ISFINITE) + if(!isfinite(p)) { + return -1; + } +#endif + if (!buf) s += 9; else { -- cgit v1.2.3