Skip to content

Commit

Permalink
Dont use errno for error checking strtold
Browse files Browse the repository at this point in the history
This leads to problems with the Xen build on travis.

Instead we perform the end pointer check and add a zero
length string check.
  • Loading branch information
andrewray committed Nov 19, 2016
1 parent dd5179f commit 5a67b89
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ctypes/ldouble_stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <float.h>
#include <math.h>
#include <complex.h>
#include <errno.h>

#include "ctypes_ldouble_stubs.h"

Expand Down Expand Up @@ -373,11 +372,12 @@ CAMLprim value ctypes_ldouble_format(value width, value prec, value d) {
CAMLprim value ctypes_ldouble_of_string(value v) {
CAMLparam1(v);
char *str = String_val(v);
char *end = str + caml_string_length(v);
int len = caml_string_length(v);
char *end;
long double r;
errno = 0;
if (0 == len) caml_invalid_argument("LDouble.of_string");
r = strtold(str, &end);
if (errno != 0 || *end != '\0') caml_invalid_argument("LDouble.of_string");
if (*end != '\0') caml_invalid_argument("LDouble.of_string");
CAMLreturn(ctypes_copy_ldouble(r));
}

Expand Down

0 comments on commit 5a67b89

Please sign in to comment.