Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb2c15a4

Browse files
committed
ImportHook: verify __import__ was not updated before overwriting it with original value
1 parent676fbb4 commitb2c15a4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

‎src/runtime/importhook.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ static void RestoreImport()
6161
{
6262
IntPtrbuiltins=Runtime.GetBuiltins();
6363

64+
IntPtrexisting=Runtime.PyObject_GetAttr(builtins,PyIdentifier.__import__);
65+
Runtime.XDecref(existing);
66+
if(existing!=hook.ptr)
67+
{
68+
thrownewNotSupportedException("Unable to restore original __import__.");
69+
}
70+
6471
intres=Runtime.PyObject_SetAttr(builtins,PyIdentifier.__import__,py_import);
6572
PythonException.ThrowIfIsNotZero(res);
6673
Runtime.XDecref(py_import);
@@ -374,6 +381,8 @@ public static IntPtr __import__(IntPtr self, IntPtr argsRaw, IntPtr kw)
374381

375382
privatestaticboolIsLoadAll(BorrowedReferencefromList)
376383
{
384+
if(fromList==null)thrownewArgumentNullException(nameof(fromList));
385+
377386
if(CLRModule.preload)
378387
{
379388
returnfalse;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp