mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0030550: Coding - Integer overflow in Standard_CString HashCodes
0030551: Foundation Classes - Integer overflow in NCollection_CellFilter HashCode Signed integers are not used in hash code functions now to prevent undefined behavior on left shift operations with signed integers. A possibility of negative values of hash codes is eliminated. INT_MAX → IntegerLast() in hash code functions. All found hash code functions behaves uniformly now: they return a value in the range [1, theUpperBound]. Relevant comments are added to such functions.
This commit is contained in:
@@ -51,15 +51,12 @@ Standard_Boolean IsEqual (const Handle(VrmlData_Node)& theOne,
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HashCode
|
||||
//purpose : Global method
|
||||
// function : HashCode
|
||||
// purpose : Global method
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer HashCode(const Handle(VrmlData_Node)& theNode,
|
||||
const Standard_Integer theUpper)
|
||||
Standard_Integer HashCode (const Handle (VrmlData_Node) & theNode, const Standard_Integer theUpperBound)
|
||||
{
|
||||
return (theNode->Name() == 0L ? 0
|
||||
: HashCode((Standard_CString)theNode->Name(), theUpper));
|
||||
return (theNode->Name () == NULL ? 1 : HashCode (theNode->Name (), theUpperBound));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -201,8 +201,12 @@ class VrmlData_Node : public Standard_Transient
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_Node, Standard_Transient)
|
||||
|
||||
Standard_EXPORT Standard_Integer HashCode(const Handle(VrmlData_Node)& theNode,
|
||||
const Standard_Integer theUpper);
|
||||
//! Computes a hash code for the given VRML node, in the range [1, theUpperBound]
|
||||
//! @param theNode the VRML node which hash code is to be computed
|
||||
//! @param theUpperBound the upper bound of the range a computing hash code must be within
|
||||
//! @return a computed hash code, in the range [1, theUpperBound]
|
||||
Standard_EXPORT Standard_Integer HashCode (const Handle (VrmlData_Node) & theNode, Standard_Integer theUpperBound);
|
||||
|
||||
Standard_EXPORT Standard_Boolean IsEqual (const Handle(VrmlData_Node)& theOne,
|
||||
const Handle(VrmlData_Node)& theTwo);
|
||||
|
||||
|
Reference in New Issue
Block a user