From b7ac0e8dec90ca8a07e1f18c42b0da5a4a4004d3 Mon Sep 17 00:00:00 2001 From: Raymond Date: Mon, 10 May 2010 14:39:49 +0200 Subject: [PATCH] Fixed unwanted Segfault + small update in UntarEx --- Units/MMLAddon/mmisc.pas | 20 ++++++++++++++++---- Units/Misc/v_ideCodeInsight.pas | 2 +- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Units/MMLAddon/mmisc.pas b/Units/MMLAddon/mmisc.pas index 9de7167..2cf83c8 100644 --- a/Units/MMLAddon/mmisc.pas +++ b/Units/MMLAddon/mmisc.pas @@ -106,7 +106,9 @@ end; function UnTar(const Input: TStream; const outputdir: string; overwrite: boolean): boolean; overload; var Tar : TTarArchive; + Succ : boolean; DirRec : TTarDirRec; + FS : TFileStream; begin; result := false; if not DirectoryExists(outputdir) then @@ -114,23 +116,33 @@ begin; exit; Tar := TTarArchive.Create(input); Tar.reset; + Succ := True; while Tar.FindNext(DirRec) do begin if (DirRec.FileType = ftDirectory) then begin; if not DirectoryExists(outputdir + DirRec.Name) and not CreateDir(outputdir + DirRec.Name) then - exit + begin + Succ := false; + break; + end; end else if (DirRec.FileType = ftNormal) then begin; if FileExists(outputdir + dirrec.name) and not overwrite then continue; - Tar.ReadFile(outputdir + dirrec.name); + try + FS := TFileStream.Create(outputdir +dirrec.name,fmCreate); + tar.ReadFile(fs); + FS.Free; + except + Succ := false; + break; + end; end else mDebugLn(format('Unknown filetype in archive. %s',[dirrec.name])); end; Tar.Free; - Result := true; - + Result := Succ; end; constructor TProcThread.Create; diff --git a/Units/Misc/v_ideCodeInsight.pas b/Units/Misc/v_ideCodeInsight.pas index d65a2b4..be5edb3 100644 --- a/Units/Misc/v_ideCodeInsight.pas +++ b/Units/Misc/v_ideCodeInsight.pas @@ -134,7 +134,7 @@ begin for i := l - 1 downto 0 do begin - if (IncludeBuffer[i].CodeInsight.FileName = FileName) then + if (IncludeBuffer[i].CodeInsight <> nil) and (IncludeBuffer[i].CodeInsight.FileName = FileName) then begin DefineMatch := (IncludeBuffer[i].DefinesIn.Defines = Defines.Defines) and (IncludeBuffer[i].DefinesIn.Stack = Defines.Stack);