* 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 -
This commit is contained in:
nickysn 2021-03-17 19:16:38 +00:00
parent 9e9859f145
commit d608b4b689

View File

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