diff --git a/main/lib/complex/ccomplex.c b/main/lib/complex/ccomplex.c index 162c87290..1d1be7e8a 100644 --- a/main/lib/complex/ccomplex.c +++ b/main/lib/complex/ccomplex.c @@ -40,6 +40,12 @@ CCOMPLEX *COMPLEX_create(double re, double im) static GB_CLASS CLASS_Complex = (GB_CLASS)NULL; CCOMPLEX *c; + if (!isfinite(re) || !isfinite(im)) + { + GB.Error(GB_ERR_MATH); + return NULL; + } + if (!CLASS_Complex) CLASS_Complex = GB.FindClass("Complex"); @@ -56,6 +62,12 @@ static inline CCOMPLEX *COMPLEX_make(CCOMPLEX *a, const double re, const double { if (a->ob.ref <= 1) { + if (!isfinite(re) || !isfinite(im)) + { + GB.Error(GB_ERR_MATH); + return NULL; + } + a->v[0] = re; a->v[1] = im; return a; diff --git a/main/share/gambas.h b/main/share/gambas.h index 30fec9aa7..fd01062d7 100644 --- a/main/share/gambas.h +++ b/main/share/gambas.h @@ -331,6 +331,7 @@ typedef #define GB_ERR_NOBJECT ((char *)12) #define GB_ERR_NWRITE ((char *)16) #define GB_ERR_NPROPERTY ((char *)17) +#define GB_ERR_MATH ((char *)19) #define GB_ERR_ARG ((char *)20) #define GB_ERR_BOUND ((char *)21) #define GB_ERR_ZERO ((char *)26)