diff --git a/src/Transforms.c b/src/Transforms.c index b6623bf..849c9c6 100644 --- a/src/Transforms.c +++ b/src/Transforms.c @@ -248,6 +248,12 @@ static int PythonFloatToOracleNumber( sword status; doubleValue = PyFloat_AS_DOUBLE(pythonValue); + if (isnan(doubleValue)) { + PyErr_SetString(g_DatabaseErrorException, + "value is not a number (NaN) and cannot be used in Oracle " + "numbers"); + return -1; + } status = OCINumberFromReal(environment->errorHandle, &doubleValue, sizeof(double), oracleValue); return Environment_CheckForError(environment, status, diff --git a/src/cx_Oracle.c b/src/cx_Oracle.c index 7d507a7..590a9ee 100644 --- a/src/cx_Oracle.c +++ b/src/cx_Oracle.c @@ -18,10 +18,18 @@ #include #include #include +#include #include #include #include +// define isnan for older versions of Visual Studio which only define _isnan +#ifdef _WIN32 +#ifndef isnan +#define isnan _isnan +#endif +#endif + // validate OCI library #if !defined(OCI_MAJOR_VERSION) || (OCI_MAJOR_VERSION < 11) || \ ((OCI_MAJOR_VERSION == 11) && (OCI_MINOR_VERSION < 2))