Browse Source

* (modified) patch by Jinyang He to handle alignment in FindInFieldTable correctly, resolves #40400

florian 2 years ago
parent
commit
c48c816e49
1 changed files with 4 additions and 0 deletions
  1. 4 0
      rtl/objpas/classes/reader.inc

+ 4 - 0
rtl/objpas/classes/reader.inc

@@ -1821,7 +1821,11 @@ var
                 and PersistenClass.InheritsFrom(TComponent) then
                 and PersistenClass.InheritsFrom(TComponent) then
               exit(TComponentClass(PersistenClass));
               exit(TComponentClass(PersistenClass));
           end;
           end;
+{$ifndef FPC_REQUIRES_PROPER_ALIGNMENT}
           FieldInfo := PFieldInfo(PByte(@FieldInfo^.Name) + 1 + Length(FieldInfo^.Name));
           FieldInfo := PFieldInfo(PByte(@FieldInfo^.Name) + 1 + Length(FieldInfo^.Name));
+{$else FPC_REQUIRES_PROPER_ALIGNMENT}
+          FieldInfo := PFieldInfo(align(PByte(@FieldInfo^.Name) + 1 + Length(FieldInfo^.Name), sizeof(SizeUInt)));
+{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
         end;
         end;
       end;
       end;
       // Try again with the parent class type
       // Try again with the parent class type