From ff8ccb06e5aaef79c003d971ede1c775e16c47d0 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Tue, 1 Jan 2019 15:08:40 +0000 Subject: [PATCH] * 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 - --- compiler/jvm/njvminl.pas | 4 ++-- compiler/ncal.pas | 14 ++++++++------ compiler/ninl.pas | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/compiler/jvm/njvminl.pas b/compiler/jvm/njvminl.pas index f73c5bff8a..866fbd01af 100644 --- a/compiler/jvm/njvminl.pas +++ b/compiler/jvm/njvminl.pas @@ -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; diff --git a/compiler/ncal.pas b/compiler/ncal.pas index d4ffb00e4c..6746543e58 100644 --- a/compiler/ncal.pas +++ b/compiler/ncal.pas @@ -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; diff --git a/compiler/ninl.pas b/compiler/ninl.pas index 22f17fcb62..7b11ebd2c1 100644 --- a/compiler/ninl.pas +++ b/compiler/ninl.pas @@ -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;