X Tutup
Skip to content
Merged
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
X Tutup