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/encode_double.c') 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 From 1a2ae45a5999850c1578e9ea0c0f993c04f934fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Tue, 2 Jun 2015 15:12:03 +0200 Subject: erl_interface: Move math.h include after eidef.h --- lib/erl_interface/src/encode/encode_double.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/erl_interface/src/encode/encode_double.c') diff --git a/lib/erl_interface/src/encode/encode_double.c b/lib/erl_interface/src/encode/encode_double.c index a19a871eda..72a1c60808 100644 --- a/lib/erl_interface/src/encode/encode_double.c +++ b/lib/erl_interface/src/encode/encode_double.c @@ -18,12 +18,12 @@ */ #include #include -#if defined(HAVE_ISFINITE) -#include -#endif #include "eidef.h" #include "eiext.h" #include "putget.h" +#if defined(HAVE_ISFINITE) +#include +#endif int ei_encode_double(char *buf, int *index, double p) { -- cgit v1.2.3 From 738c34d4bb8f1a3811acd00af8c6c12107f8315b Mon Sep 17 00:00:00 2001 From: Bruce Yinhe Date: Thu, 18 Jun 2015 11:31:02 +0200 Subject: Change license text to APLv2 --- lib/erl_interface/src/encode/encode_double.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'lib/erl_interface/src/encode/encode_double.c') diff --git a/lib/erl_interface/src/encode/encode_double.c b/lib/erl_interface/src/encode/encode_double.c index 72a1c60808..8943cefa11 100644 --- a/lib/erl_interface/src/encode/encode_double.c +++ b/lib/erl_interface/src/encode/encode_double.c @@ -3,16 +3,17 @@ * * Copyright Ericsson AB 1998-2010. All Rights Reserved. * - * The contents of this file are subject to the Erlang Public License, - * Version 1.1, (the "License"); you may not use this file except in - * compliance with the License. You should have received a copy of the - * Erlang Public License along with this software. If not, it can be - * retrieved online at http://www.erlang.org/. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and limitations - * under the License. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. * * %CopyrightEnd% */ -- cgit v1.2.3