File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,8 @@ public static int magic(IntPtr type)
185185
186186 public static int TypeDictOffset ( IntPtr type )
187187 {
188- return ManagedDataOffsets . DictOffset ( type ) ;
188+ Debug . Assert ( TypeOffset . tp_dictoffset > 0 ) ;
189+ return Marshal . ReadInt32 ( type , TypeOffset . tp_dictoffset ) ;
189190 }
190191
191192 public static int Size ( IntPtr pyType )
Original file line number Diff line number Diff line change @@ -260,13 +260,17 @@ protected static void ClearObjectDict(IntPtr ob)
260260 protected static IntPtr GetObjectDict ( IntPtr ob )
261261 {
262262 IntPtr type = Runtime . PyObject_TYPE ( ob ) ;
263- return Marshal . ReadIntPtr ( ob , ObjectOffset . TypeDictOffset ( type ) ) ;
263+ int dictOffset = ObjectOffset . TypeDictOffset ( type ) ;
264+ if ( dictOffset == 0 ) return IntPtr . Zero ;
265+ return Marshal . ReadIntPtr ( ob , dictOffset ) ;
264266 }
265267
266268 protected static void SetObjectDict ( IntPtr ob , IntPtr value )
267269 {
268270 IntPtr type = Runtime . PyObject_TYPE ( ob ) ;
269- Marshal . WriteIntPtr ( ob , ObjectOffset . TypeDictOffset ( type ) , value ) ;
271+ int dictOffset = ObjectOffset . TypeDictOffset ( type ) ;
272+ Debug . Assert ( dictOffset > 0 ) ;
273+ Marshal . WriteIntPtr ( ob , dictOffset , value ) ;
270274 }
271275 }
272276}
You can’t perform that action at this time.
0 commit comments