* 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;
begin
{ 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 }
if not is_shortstring(left.resultdef) and
not assigned(tcallparanode(tcallparanode(left).right).right) and
@ -535,7 +535,7 @@ implementation
{ strings are handled the same as on other platforms }
if left.resultdef.typ=stringdef then
begin
left:=reverseparameters(tcallparanode(left));
reverseparameters(tcallparanode(left));
result:=inherited first_setlength;
exit;
end;

View File

@ -292,7 +292,7 @@ interface
dct_propput
);
function reverseparameters(p: tcallparanode): tcallparanode;
procedure reverseparameters(var p: tcallparanode);
function translate_disp_call(selfnode,parametersnode: tnode; calltype: tdispcalltype; const methodname : ansistring;
dispid : longint;resultdef : tdef) : tnode;
@ -333,21 +333,23 @@ implementation
HELPERS
****************************************************************************}
function reverseparameters(p: tcallparanode): tcallparanode;
procedure reverseparameters(var p: tcallparanode);
var
tmpp,
hp1, hp2: tcallparanode;
begin
hp1:=nil;
while assigned(p) do
tmpp:=p;
while assigned(tmpp) do
begin
{ pull out }
hp2:=p;
p:=tcallparanode(p.right);
hp2:=tmpp;
tmpp:=tcallparanode(tmpp.right);
{ pull in }
hp2.right:=hp1;
hp1:=hp2;
end;
reverseparameters:=hp1;
p:=hp1;
end;
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 }
{ correct order when processing write(ln) }
left := reverseparameters(tcallparanode(left));
reverseparameters(tcallparanode(left));
if is_rwstr then
begin
@ -1526,7 +1526,7 @@ implementation
valsinttype:=search_system_type('VALSINT').typedef;
{ reverse parameters for easier processing }
left := reverseparameters(tcallparanode(left));
reverseparameters(tcallparanode(left));
{ get the parameters }
tempcode := nil;