* changed reverseparameters() from function into procedure: it does not make

sense as a function (the original input needed to be replaced by its
    result to make any sense), and someone already mistakenly used it like that
    in htypechk causing a bug/memory leak

git-svn-id: trunk@40729 -
This commit is contained in:
Jonas Maebe 2019-01-01 15:08:40 +00:00
parent 9d079bfb97
commit ff8ccb06e5
3 changed files with 12 additions and 10 deletions

View File

@ -521,7 +521,7 @@ implementation
function tjvminlinenode.first_setlength: tnode; function tjvminlinenode.first_setlength: tnode;
begin begin
{ reverse the parameter order so we can process them more easily } { reverse the parameter order so we can process them more easily }
left:=reverseparameters(tcallparanode(left)); reverseparameters(tcallparanode(left));
{ treat setlength(x,0) specially: used to init uninitialised locations } { treat setlength(x,0) specially: used to init uninitialised locations }
if not is_shortstring(left.resultdef) and if not is_shortstring(left.resultdef) and
not assigned(tcallparanode(tcallparanode(left).right).right) and not assigned(tcallparanode(tcallparanode(left).right).right) and
@ -535,7 +535,7 @@ implementation
{ strings are handled the same as on other platforms } { strings are handled the same as on other platforms }
if left.resultdef.typ=stringdef then if left.resultdef.typ=stringdef then
begin begin
left:=reverseparameters(tcallparanode(left)); reverseparameters(tcallparanode(left));
result:=inherited first_setlength; result:=inherited first_setlength;
exit; exit;
end; end;

View File

@ -292,7 +292,7 @@ interface
dct_propput dct_propput
); );
function reverseparameters(p: tcallparanode): tcallparanode; procedure reverseparameters(var p: tcallparanode);
function translate_disp_call(selfnode,parametersnode: tnode; calltype: tdispcalltype; const methodname : ansistring; function translate_disp_call(selfnode,parametersnode: tnode; calltype: tdispcalltype; const methodname : ansistring;
dispid : longint;resultdef : tdef) : tnode; dispid : longint;resultdef : tdef) : tnode;
@ -333,21 +333,23 @@ implementation
HELPERS HELPERS
****************************************************************************} ****************************************************************************}
function reverseparameters(p: tcallparanode): tcallparanode; procedure reverseparameters(var p: tcallparanode);
var var
tmpp,
hp1, hp2: tcallparanode; hp1, hp2: tcallparanode;
begin begin
hp1:=nil; hp1:=nil;
while assigned(p) do tmpp:=p;
while assigned(tmpp) do
begin begin
{ pull out } { pull out }
hp2:=p; hp2:=tmpp;
p:=tcallparanode(p.right); tmpp:=tcallparanode(tmpp.right);
{ pull in } { pull in }
hp2.right:=hp1; hp2.right:=hp1;
hp1:=hp2; hp1:=hp2;
end; end;
reverseparameters:=hp1; p:=hp1;
end; end;
function translate_disp_call(selfnode,parametersnode: tnode; calltype: tdispcalltype; const methodname : ansistring; function translate_disp_call(selfnode,parametersnode: tnode; calltype: tdispcalltype; const methodname : ansistring;

View File

@ -1240,7 +1240,7 @@ implementation
{ reverse the parameters (needed to get the colon parameters in the } { reverse the parameters (needed to get the colon parameters in the }
{ correct order when processing write(ln) } { correct order when processing write(ln) }
left := reverseparameters(tcallparanode(left)); reverseparameters(tcallparanode(left));
if is_rwstr then if is_rwstr then
begin begin
@ -1526,7 +1526,7 @@ implementation
valsinttype:=search_system_type('VALSINT').typedef; valsinttype:=search_system_type('VALSINT').typedef;
{ reverse parameters for easier processing } { reverse parameters for easier processing }
left := reverseparameters(tcallparanode(left)); reverseparameters(tcallparanode(left));
{ get the parameters } { get the parameters }
tempcode := nil; tempcode := nil;