Skip to content

Commit b89fa1f

Browse files
committed
Add null checks for Project to prevent access violations #29
1 parent 893585f commit b89fa1f

1 file changed

Lines changed: 23 additions & 15 deletions

File tree

Source/ObjectSpace/IDE/BoldComponentValidatorIDE.pas

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,11 @@ procedure TBoldComponentValidatorIDE.ValidateIOTAModules;
142142
if ModuleServices.GetModule(i).QueryInterface(IOTAProjectGroup, ProjectGroup) = S_OK then
143143
begin
144144
Project := ProjectGroup.ActiveProject;
145-
BoldLog.LogFmt(sDefaultProject, [Project.FileName]);
146-
Break;
145+
if Assigned(Project) then
146+
begin
147+
BoldLog.LogFmt(sDefaultProject, [Project.FileName]);
148+
Break;
149+
end;
147150
end;
148151
end;
149152
BoldLog.Dedent;
@@ -164,22 +167,27 @@ procedure TBoldComponentValidatorIDE.ValidateIOTAModules;
164167
BoldLog.Dedent;
165168

166169
ChangeFocus;
167-
BoldLog.ProgressMax := Project.GetModuleCount - 1;
168-
BoldLog.Progress := 0;
169-
for i := 0 to Project.GetModuleCount - 1 do
170+
if Assigned(Project) then
170171
begin
171-
OTAModuleInfo := Project.GetModule(i);
172-
try
173-
Module := OTAModuleInfo.OpenModule;
174-
if FileNames.IndexOf(Module.FileName) = - 1 then
175-
begin
176-
ValidateIOTAModule(Module);
177-
Module.CloseModule(True);
172+
BoldLog.ProgressMax := Project.GetModuleCount - 1;
173+
BoldLog.Progress := 0;
174+
for i := 0 to Project.GetModuleCount - 1 do
175+
begin
176+
OTAModuleInfo := Project.GetModule(i);
177+
try
178+
Module := OTAModuleInfo.OpenModule;
179+
if FileNames.IndexOf(Module.FileName) = - 1 then
180+
begin
181+
ValidateIOTAModule(Module);
182+
Module.CloseModule(True);
183+
end;
184+
BoldLog.ProgressStep;
185+
except
178186
end;
179-
BoldLog.ProgressStep;
180-
except
181187
end;
182-
end;
188+
end
189+
else
190+
BoldLog.Log('No project found to validate');
183191
BoldLog.EndLog;
184192
end;
185193

0 commit comments

Comments
 (0)