mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-05-16 10:54:53 +03:00
0031008: Application Framework - memcpy-param-overlap reported by Clang address sanitizer in LDOM_XmlReader::ReadRecord()
Use memmove instead of memcpy because of copy of the possible overlapped source and destination parts of the buffer.
This commit is contained in:
parent
2724a0b3cc
commit
3358ed643b
@ -112,17 +112,20 @@ LDOM_XmlReader::RecordType LDOM_XmlReader::ReadRecord (Standard_IStream& theIStr
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we are reading some data, save the beginning and preserve the state
|
||||
// If we are reading some data, save the beginning and preserve the state
|
||||
if (aStartData /* && aState != STATE_WAITING */) {
|
||||
if (myPtr > aStartData)
|
||||
theData.rdbuf()->sputn(aStartData, myPtr - aStartData);
|
||||
aStartData = &myBuffer[0];
|
||||
}
|
||||
// Copy the rest of file data to the beginning of buffer
|
||||
// Copy the rest of file data to the beginning of buffer
|
||||
if (aBytesRest > 0)
|
||||
memcpy (&myBuffer[0], myPtr, aBytesRest);
|
||||
{
|
||||
// do not use memcpy here because aBytesRest may be greater than myPtr-myBuffer, so, overlap
|
||||
memmove (&myBuffer[0], myPtr, aBytesRest);
|
||||
}
|
||||
|
||||
// Read the full buffer and reset start and end buffer pointers
|
||||
// Read the full buffer and reset start and end buffer pointers
|
||||
myPtr = &myBuffer[0];
|
||||
Standard_Size aNBytes;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user