Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update converter.cs #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/runtime/converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,10 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
goto type_error;
}
ival = Runtime.PyInt_AsLong(op);
Runtime.Decref(op);
if (ival > Char.MaxValue || ival < Char.MinValue) {
goto overflow;
}
Runtime.Decref(op);
result = (char)ival;
return true;

Expand Down Expand Up @@ -644,14 +644,16 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
goto type_error;
}
uint ui = (uint)Runtime.PyLong_AsUnsignedLong(op);
Runtime.Decref(op);

if (Exceptions.ErrorOccurred()) {
Runtime.Decref(op);
goto overflow;
}

IntPtr check = Runtime.PyLong_FromUnsignedLong(ui);
int err = Runtime.PyObject_Compare(check, op);
Runtime.Decref(check);
Runtime.Decref(op);
if (0 != err || Exceptions.ErrorOccurred()) {
goto overflow;
}
Expand Down Expand Up @@ -684,7 +686,8 @@ static bool ToPrimitive(IntPtr value, Type obType, out Object result,
}
goto type_error;
}
double dd = Runtime.PyFloat_AsDouble(value);
double dd = Runtime.PyFloat_AsDouble(op);
Runtime.Decref(op);
if (dd > Single.MaxValue || dd < Single.MinValue) {
goto overflow;
}
Expand Down