1. "wcslen" function was called multiple times with "const wchar_t* Path"
2. fix mistake which led to undefined behavior "uint64(High<<32)" -> "uint64(High)<<32" 3. optimize std::vector<>::iterator's usage "iter++" -> "++iter". See preincrement and postincrement operator++()
This commit is contained in:
parent
0f99c2d712
commit
af339a7a7a
@ -65,7 +65,7 @@ EbmlMaster::EbmlMaster(const EbmlMaster & ElementToClone)
|
||||
while (Itr != ElementToClone.ElementList.end())
|
||||
{
|
||||
*myItr = (*Itr)->Clone();
|
||||
Itr++; myItr++;
|
||||
++Itr; ++myItr;
|
||||
}
|
||||
|
||||
}
|
||||
@ -524,7 +524,7 @@ bool EbmlMaster::InsertElement(EbmlElement & element, size_t position)
|
||||
std::vector<EbmlElement *>::iterator Itr = ElementList.begin();
|
||||
while (Itr != ElementList.end() && position--)
|
||||
{
|
||||
Itr++;
|
||||
++Itr;
|
||||
}
|
||||
if ((Itr == ElementList.end()) && position)
|
||||
return false;
|
||||
@ -538,7 +538,7 @@ bool EbmlMaster::InsertElement(EbmlElement & element, const EbmlElement & before
|
||||
std::vector<EbmlElement *>::iterator Itr = ElementList.begin();
|
||||
while (Itr != ElementList.end() && *Itr != &before)
|
||||
{
|
||||
Itr++;
|
||||
++Itr;
|
||||
}
|
||||
if (Itr == ElementList.end())
|
||||
return false;
|
||||
|
@ -153,10 +153,11 @@ bool WinIOCallback::open(const wchar_t* Path, const open_mode aMode, DWORD dwFla
|
||||
mFile = CreateFileW(Path, AccessMode, ShareMode, NULL, Disposition, dwFlags, NULL);
|
||||
} else {
|
||||
int errCode;
|
||||
unsigned int bufferSize = wcslen(Path) + sizeof(wchar_t) * 2;
|
||||
int pathSize = wcslen(Path);
|
||||
unsigned int bufferSize = pathSize + sizeof(wchar_t) * 2;
|
||||
std::string PathA;
|
||||
PathA.resize(bufferSize);
|
||||
errCode = WideCharToMultiByte(CP_ACP, 0, Path, wcslen(Path), (char *)PathA.c_str(), bufferSize, NULL, NULL);
|
||||
errCode = WideCharToMultiByte(CP_ACP, 0, Path, pathSize, (char *)PathA.c_str(), bufferSize, NULL, NULL);
|
||||
if (errCode == 0)
|
||||
errCode = GetLastError();
|
||||
#ifdef _DEBUG
|
||||
@ -168,7 +169,7 @@ bool WinIOCallback::open(const wchar_t* Path, const open_mode aMode, DWORD dwFla
|
||||
// Increase the buffer size
|
||||
bufferSize += MAX_PATH;
|
||||
PathA.resize(bufferSize);
|
||||
errCode = WideCharToMultiByte(CP_ACP, WC_SEPCHARS, Path, wcslen(Path), (char *)PathA.c_str(), bufferSize, NULL, NULL);
|
||||
errCode = WideCharToMultiByte(CP_ACP, WC_SEPCHARS, Path, pathSize, (char *)PathA.c_str(), bufferSize, NULL, NULL);
|
||||
if (errCode == 0)
|
||||
errCode = GetLastError();
|
||||
}
|
||||
@ -251,7 +252,7 @@ void WinIOCallback::setFilePointer(int64 Offset, seek_mode Mode)
|
||||
}
|
||||
else
|
||||
{
|
||||
mCurrentPosition |= uint64(High<<32);
|
||||
mCurrentPosition |= uint64(High)<<32;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user