@@ -227,22 +227,26 @@ __tysan_check(void *addr, int size, tysan_type_descriptor *td, int flags) {
227
227
int i = -((sptr)OldTD);
228
228
OldTDPtr -= i;
229
229
OldTD = *OldTDPtr;
230
-
231
- // When shadow memory is set for global objects, the entire object is tagged
232
- // with the struct type This means that when you access a member variable,
233
- // tysan reads that as you accessing a struct midway through, with 'i' being
234
- // the offset Therefore, if you are accessing a struct, we need to find the
235
- // member type. We can go through the members of the struct type and see if
236
- // there is a member at the offset you are accessing the struct by. If there
237
- // is indeed a member starting at offset 'i' in the struct, we should check
238
- // aliasing legality with that type. If there isn't, we run alias checking
239
- // on the struct which will give us the correct error.
230
+
240
231
tysan_type_descriptor *AccessedType = OldTD;
241
- if (OldTD->Tag == TYSAN_STRUCT_TD) {
242
- for (int j = 0 ; j < OldTD->Struct .MemberCount ; ++j) {
243
- if (OldTD->Struct .Members [j].Offset == i) {
244
- AccessedType = OldTD->Struct .Members [j].Type ;
245
- break ;
232
+
233
+ // Only check if we are accessing members if the type exists
234
+ if (OldTD != nullptr ){
235
+ // When shadow memory is set for global objects, the entire object is tagged
236
+ // with the struct type This means that when you access a member variable,
237
+ // tysan reads that as you accessing a struct midway through, with 'i' being
238
+ // the offset Therefore, if you are accessing a struct, we need to find the
239
+ // member type. We can go through the members of the struct type and see if
240
+ // there is a member at the offset you are accessing the struct by. If there
241
+ // is indeed a member starting at offset 'i' in the struct, we should check
242
+ // aliasing legality with that type. If there isn't, we run alias checking
243
+ // on the struct which will give us the correct error.
244
+ if (OldTD->Tag == TYSAN_STRUCT_TD) {
245
+ for (int j = 0 ; j < OldTD->Struct .MemberCount ; ++j) {
246
+ if (OldTD->Struct .Members [j].Offset == i) {
247
+ AccessedType = OldTD->Struct .Members [j].Type ;
248
+ break ;
249
+ }
246
250
}
247
251
}
248
252
}
0 commit comments