1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-08 18:40:55 +03:00

0022970: Incorrect array use in Graphic3d_StructureManager.cxx

Corrected bounds of loops and initialisation error message.
This commit is contained in:
aba 2012-10-25 14:07:11 +04:00
parent bcfa72e4b3
commit f163f612f9

View File

@ -93,14 +93,14 @@ Standard_Integer Limit = Graphic3d_StructureManager::Limit ();
Initialisation = Standard_False; Initialisation = Standard_False;
/* table to manage IDs of StructureManager */ /* table to manage IDs of StructureManager */
for (i=1; i<=Limit; i++) StructureManager_ArrayId[i] = 0; for (i=0; i<Limit; i++) StructureManager_ArrayId[i] = 0;
StructureManager_CurrentId = 1; StructureManager_CurrentId = 0;
StructureManager_ArrayId[1] = 1; StructureManager_ArrayId[0] = 1;
} }
else { else {
for (i=1; i<=Limit && NotFound; i++) for (i=0; i<Limit && NotFound; i++)
if (StructureManager_ArrayId[i] == 0) { if (StructureManager_ArrayId[i] == 0) {
NotFound = Standard_False; NotFound = Standard_False;
StructureManager_CurrentId = i; StructureManager_CurrentId = i;
@ -108,14 +108,18 @@ Standard_Integer Limit = Graphic3d_StructureManager::Limit ();
} }
if (NotFound) if (NotFound)
Graphic3d_InitialisationError::Raise {
("Too many ViewManagers are defined"); Standard_SStream anErrorDescription;
anErrorDescription<<"You are trying to create too many ViewManagers at the same time!\n"<<
"The number of simultaneously created ViewManagers can't exceed "<<Limit<<".\n";
Graphic3d_InitialisationError::Raise(anErrorDescription);
}
} }
Coef = (Structure_IDMIN+Structure_IDMAX)/Limit; Coef = (Structure_IDMIN+Structure_IDMAX)/Limit;
Aspect_GenId theGenId( Aspect_GenId theGenId(
Standard_Integer (Structure_IDMIN+Coef*(StructureManager_CurrentId-1)), Standard_Integer (Structure_IDMIN+Coef*(StructureManager_CurrentId)),
Standard_Integer (Structure_IDMIN+Coef*StructureManager_CurrentId-1)); Standard_Integer (Structure_IDMIN+Coef*(StructureManager_CurrentId+1)-1));
MyStructGenId = theGenId; MyStructGenId = theGenId;
MyId = StructureManager_CurrentId; MyId = StructureManager_CurrentId;