Переглянути джерело

* instead of registering all and then deleting non-propgetter/setter procdefs in
pdecvar.read_property_dec, don't register them by default, and then only
register them, if they are propgetter/setter. This prevents dangling pointers
in current_module.deflist and potential use-after-free bugs.

git-svn-id: trunk@48998 -

nickysn 4 роки тому
батько
коміт
d608b4b689
1 змінених файлів з 10 додано та 7 видалено
  1. 10 7
      compiler/pdecvar.pas

+ 10 - 7
compiler/pdecvar.pas

@@ -360,8 +360,8 @@ implementation
          { Generate temp procdefs to search for matching read/write
            procedures. the readprocdef will store all definitions }
          paranr:=0;
-         readprocdef:=cprocdef.create(normal_function_level,true);
-         writeprocdef:=cprocdef.create(normal_function_level,true);
+         readprocdef:=cprocdef.create(normal_function_level,false);
+         writeprocdef:=cprocdef.create(normal_function_level,false);
 
          readprocdef.struct:=astruct;
          writeprocdef.struct:=astruct;
@@ -857,11 +857,14 @@ implementation
                message1(parser_e_implements_uses_non_implemented_interface,def.typename);
            until not try_to_consume(_COMMA);
 
-         { remove unneeded procdefs }
-         if readprocdef.proctypeoption<>potype_propgetter then
-           readprocdef.owner.deletedef(readprocdef);
-         if writeprocdef.proctypeoption<>potype_propsetter then
-           writeprocdef.owner.deletedef(writeprocdef);
+         { register propgetter and propsetter procdefs }
+         if assigned(current_module) and current_module.in_interface then
+           begin
+             if readprocdef.proctypeoption=potype_propgetter then
+               readprocdef.register_def;
+             if writeprocdef.proctypeoption=potype_propsetter then
+               writeprocdef.register_def;
+           end;
 
          result:=p;
       end;