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

Skip to content

Commit 6deab92

Browse files
committed
added a few error checks
1 parent cf8d97b commit 6deab92

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/runtime/pyobject.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ public object AsManagedObject(Type t)
165165
/// </remarks>
166166
protected virtual void Dispose(bool disposing)
167167
{
168+
DebugUtil.EnsureGIL();
169+
168170
if (this.obj == IntPtr.Zero)
169171
{
170172
return;

src/runtime/runtime.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,9 +1536,10 @@ internal static string GetManagedString(IntPtr op)
15361536
if (type == PyUnicodeType)
15371537
{
15381538
IntPtr p = PyUnicode_AsUnicode(op);
1539-
int length = (int)PyUnicode_GetSize(op);
1539+
Exceptions.ErrorCheck(p);
1540+
int length = checked((int)PyUnicode_GetSize(op));
15401541

1541-
int size = length * UCS;
1542+
int size = checked(length * UCS);
15421543
var buffer = new byte[size];
15431544
Marshal.Copy(p, buffer, 0, size);
15441545
return PyEncoding.GetString(buffer, 0, size);

0 commit comments

Comments
 (0)