From 54f1890fea7841c4e98ff6bee494ca9d1222601d Mon Sep 17 00:00:00 2001 From: yury Date: Tue, 7 Mar 2017 10:14:59 +0000 Subject: [PATCH] * Fixed memory leak of tlabelnode.labsym. git-svn-id: trunk@35538 - --- compiler/nflw.pas | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/compiler/nflw.pas b/compiler/nflw.pas index c43bbd84e5..78528b350e 100644 --- a/compiler/nflw.pas +++ b/compiler/nflw.pas @@ -2033,10 +2033,18 @@ implementation destructor tlabelnode.destroy; begin - { Remove reference in labelsym, this is to prevent - goto's to this label } - if assigned(labsym) and (labsym.code=pointer(self)) then - labsym.code:=nil; + if assigned(labsym) then + begin + if not assigned(labsym.Owner) then + labsym.Free // Free labelsym if it has no owner + else + if labsym.code=pointer(self) then + begin + { Remove reference in labelsym, this is to prevent + goto's to this label } + labsym.code:=nil; + end; + end; inherited destroy; end;