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

Commitaf52ee5

Browse files
committed
improved handling of dict offset in object instances
1 parente5bce06 commitaf52ee5

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

‎src/runtime/interop.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ public static int magic(IntPtr type)
185185

186186
publicstaticintTypeDictOffset(IntPtrtype)
187187
{
188-
returnManagedDataOffsets.DictOffset(type);
188+
Debug.Assert(TypeOffset.tp_dictoffset>0);
189+
returnMarshal.ReadInt32(type,TypeOffset.tp_dictoffset);
189190
}
190191

191192
publicstaticintSize(IntPtrpyType)

‎src/runtime/managedtype.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,17 @@ protected static void ClearObjectDict(IntPtr ob)
260260
protectedstaticIntPtrGetObjectDict(IntPtrob)
261261
{
262262
IntPtrtype=Runtime.PyObject_TYPE(ob);
263-
returnMarshal.ReadIntPtr(ob,ObjectOffset.TypeDictOffset(type));
263+
intdictOffset=ObjectOffset.TypeDictOffset(type);
264+
if(dictOffset==0)returnIntPtr.Zero;
265+
returnMarshal.ReadIntPtr(ob,dictOffset);
264266
}
265267

266268
protectedstaticvoidSetObjectDict(IntPtrob,IntPtrvalue)
267269
{
268270
IntPtrtype=Runtime.PyObject_TYPE(ob);
269-
Marshal.WriteIntPtr(ob,ObjectOffset.TypeDictOffset(type),value);
271+
intdictOffset=ObjectOffset.TypeDictOffset(type);
272+
Debug.Assert(dictOffset>0);
273+
Marshal.WriteIntPtr(ob,dictOffset,value);
270274
}
271275
}
272276
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp