@@ -433,9 +433,9 @@ bool CLR_RT_Thread::FindEhBlock(
433
433
_ASSERTE (from);
434
434
// onlyFinallys is false when we're searching for a handler for an exception, and to should be nullptr
435
435
_ASSERTE (FIMPLIES (!onlyFinallys, to == nullptr ));
436
- // onlyFinallys is true in Phase2, endfinally, leave, etc. to is nullptr when we want to leave outside of the current
437
- // stack frame, or non-nullptr and pointing to an IL instruction that we are going to when finally's, if any, are
438
- // processed.
436
+ // onlyFinallys is true in Phase2, endfinally, leave, etc. to is nullptr when we want to leave outside of the
437
+ // current stack frame, or non-nullptr and pointing to an IL instruction that we are going to when finally's, if
438
+ // any, are processed.
439
439
440
440
#if defined(NANOCLR_TRACE_EXCEPTIONS)
441
441
if (CLR_EE_DBG_IS_NOT (NoStackTraceInExceptions) && s_CLR_RT_fTrace_Exceptions >= c_CLR_RT_Trace_Annoying)
@@ -936,7 +936,10 @@ HRESULT CLR_RT_Thread::Execute_DelegateInvoke(CLR_RT_StackFrame &stackArg)
936
936
937
937
ptr = &stack->m_arguments [0 ];
938
938
if (ptr->DataType () != DATATYPE_OBJECT)
939
+ {
939
940
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
941
+ }
942
+
940
943
dlg = ptr->DereferenceDelegate ();
941
944
FAULT_ON_NULL (dlg);
942
945
@@ -2171,9 +2174,9 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
2171
2174
NANOCLR_CHECK_HRESULT (CLR_RT_TypeDescriptor::ExtractTypeIndexFromObject (pThis[0 ], cls));
2172
2175
2173
2176
// This test is for performance reasons. c# emits a callvirt on all instance methods to
2174
- // make sure that a NullReferenceException is thrown if 'this' is nullptr. However, if the
2175
- // instance method isn't virtual we don't need to do the more expensive virtual method
2176
- // lookup.
2177
+ // make sure that a NullReferenceException is thrown if 'this' is nullptr. However, if
2178
+ // the instance method isn't virtual we don't need to do the more expensive virtual
2179
+ // method lookup.
2177
2180
if (op == CEE_CALLVIRT &&
2178
2181
(calleeInst.target ->flags &
2179
2182
(CLR_RECORD_METHODDEF::MD_Abstract | CLR_RECORD_METHODDEF::MD_Virtual)))
@@ -2290,7 +2293,9 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
2290
2293
CLR_RT_TypeDef_Index cls;
2291
2294
2292
2295
if (type.ResolveToken (arg, assm, &stack->m_call ) == false )
2296
+ {
2293
2297
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
2298
+ }
2294
2299
2295
2300
NANOCLR_CHECK_HRESULT (CLR_RT_TypeDescriptor::ExtractTypeIndexFromObject (evalPos[0 ], cls));
2296
2301
@@ -2530,7 +2535,10 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
2530
2535
2531
2536
CLR_RT_FieldDef_Instance fieldInst;
2532
2537
if (fieldInst.ResolveToken (arg, assm) == false )
2538
+ {
2533
2539
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
2540
+ }
2541
+
2534
2542
CLR_RT_HeapBlock *obj = &evalPos[0 ];
2535
2543
NanoCLRDataType dt = obj->DataType ();
2536
2544
@@ -2580,7 +2588,10 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
2580
2588
2581
2589
CLR_RT_FieldDef_Instance fieldInst;
2582
2590
if (fieldInst.ResolveToken (arg, assm) == false )
2591
+ {
2583
2592
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
2593
+ }
2594
+
2584
2595
CLR_RT_HeapBlock *obj = &evalPos[0 ];
2585
2596
NanoCLRDataType dt = obj->DataType ();
2586
2597
@@ -2699,7 +2710,9 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
2699
2710
2700
2711
CLR_RT_FieldDef_Instance field;
2701
2712
if (field.ResolveToken (arg, assm) == false )
2713
+ {
2702
2714
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
2715
+ }
2703
2716
2704
2717
CLR_RT_HeapBlock *ptr = CLR_RT_ExecutionEngine::AccessStaticField (field);
2705
2718
@@ -2724,7 +2737,9 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
2724
2737
2725
2738
CLR_RT_FieldDef_Instance field;
2726
2739
if (field.ResolveToken (arg, assm) == false )
2740
+ {
2727
2741
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
2742
+ }
2728
2743
2729
2744
CLR_RT_HeapBlock *ptr = CLR_RT_ExecutionEngine::AccessStaticField (field);
2730
2745
@@ -2780,7 +2795,9 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
2780
2795
2781
2796
CLR_RT_TypeDef_Instance typeInst{};
2782
2797
if (typeInst.ResolveToken (arg, assm, &stack->m_call ) == false )
2798
+ {
2783
2799
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
2800
+ }
2784
2801
2785
2802
UPDATESTACK (stack, evalPos);
2786
2803
@@ -2831,7 +2848,9 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
2831
2848
{
2832
2849
hr = CLR_RT_HeapBlock_Array::CreateInstance (evalPos[0 ], size, assm, arg);
2833
2850
if (SUCCEEDED (hr))
2851
+ {
2834
2852
break ;
2853
+ }
2835
2854
2836
2855
// if we have an out of memory exception, perform a compaction and try again.
2837
2856
if (hr == CLR_E_OUT_OF_MEMORY && pass == 0 )
@@ -2938,13 +2957,17 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
2938
2957
CLR_RT_TypeDef_Index cls;
2939
2958
2940
2959
if (!type.ResolveToken (arg, assm, &stack->m_call ))
2960
+ {
2941
2961
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
2962
+ }
2942
2963
2943
2964
NANOCLR_CHECK_HRESULT (CLR_RT_TypeDescriptor::ExtractTypeIndexFromObject (evalPos[0 ], cls));
2944
2965
2945
2966
// Check this is an object of the requested type.
2946
2967
if (type.data != cls.data )
2968
+ {
2947
2969
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
2970
+ }
2948
2971
2949
2972
UPDATESTACK (stack, evalPos);
2950
2973
{
@@ -3130,7 +3153,9 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
3130
3153
{
3131
3154
CLR_RT_TypeSpec_Instance sig{};
3132
3155
if (sig.ResolveToken (arg, assm) == false )
3156
+ {
3133
3157
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
3158
+ }
3134
3159
3135
3160
evalPos[0 ].SetReflection (sig);
3136
3161
}
@@ -3141,7 +3166,9 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
3141
3166
{
3142
3167
CLR_RT_TypeDef_Instance cls{};
3143
3168
if (cls.ResolveToken (arg, assm, &stack->m_call ) == false )
3169
+ {
3144
3170
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
3171
+ }
3145
3172
3146
3173
evalPos[0 ].SetReflection (cls);
3147
3174
}
@@ -3152,7 +3179,9 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
3152
3179
{
3153
3180
CLR_RT_FieldDef_Instance field;
3154
3181
if (field.ResolveToken (arg, assm) == false )
3182
+ {
3155
3183
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
3184
+ }
3156
3185
3157
3186
evalPos[0 ].SetReflection (field);
3158
3187
}
@@ -3163,7 +3192,9 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
3163
3192
{
3164
3193
CLR_RT_MethodDef_Instance method{};
3165
3194
if (method.ResolveToken (arg, assm) == false )
3195
+ {
3166
3196
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
3197
+ }
3167
3198
3168
3199
evalPos[0 ].SetReflection (method);
3169
3200
}
@@ -3329,7 +3360,9 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
3329
3360
3330
3361
CLR_RT_MethodDef_Instance method{};
3331
3362
if (method.ResolveToken (arg, assm) == false )
3363
+ {
3332
3364
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
3365
+ }
3333
3366
3334
3367
UPDATESTACK (stack, evalPos);
3335
3368
@@ -3345,7 +3378,10 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
3345
3378
3346
3379
CLR_RT_MethodDef_Instance callee{};
3347
3380
if (callee.ResolveToken (arg, assm) == false )
3381
+ {
3348
3382
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
3383
+ }
3384
+
3349
3385
CLR_RT_TypeDef_Index cls;
3350
3386
3351
3387
NANOCLR_CHECK_HRESULT (CLR_RT_TypeDescriptor::ExtractTypeIndexFromObject (evalPos[0 ], cls));
@@ -3410,7 +3446,10 @@ HRESULT CLR_RT_Thread::Execute_IL(CLR_RT_StackFrame &stackArg)
3410
3446
3411
3447
CLR_RT_TypeDef_Instance clsInst{};
3412
3448
if (clsInst.ResolveToken (arg, assm, &stack->m_call ) == false )
3449
+ {
3413
3450
NANOCLR_SET_AND_LEAVE (CLR_E_WRONG_TYPE);
3451
+ }
3452
+
3414
3453
CLR_INT32 len;
3415
3454
3416
3455
if (clsInst.target ->dataType )
0 commit comments