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())
|
while (Itr != ElementToClone.ElementList.end())
|
||||||
{
|
{
|
||||||
*myItr = (*Itr)->Clone();
|
*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();
|
std::vector<EbmlElement *>::iterator Itr = ElementList.begin();
|
||||||
while (Itr != ElementList.end() && position--)
|
while (Itr != ElementList.end() && position--)
|
||||||
{
|
{
|
||||||
Itr++;
|
++Itr;
|
||||||
}
|
}
|
||||||
if ((Itr == ElementList.end()) && position)
|
if ((Itr == ElementList.end()) && position)
|
||||||
return false;
|
return false;
|
||||||
@ -538,7 +538,7 @@ bool EbmlMaster::InsertElement(EbmlElement & element, const EbmlElement & before
|
|||||||
std::vector<EbmlElement *>::iterator Itr = ElementList.begin();
|
std::vector<EbmlElement *>::iterator Itr = ElementList.begin();
|
||||||
while (Itr != ElementList.end() && *Itr != &before)
|
while (Itr != ElementList.end() && *Itr != &before)
|
||||||
{
|
{
|
||||||
Itr++;
|
++Itr;
|
||||||
}
|
}
|
||||||
if (Itr == ElementList.end())
|
if (Itr == ElementList.end())
|
||||||
return false;
|
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);
|
mFile = CreateFileW(Path, AccessMode, ShareMode, NULL, Disposition, dwFlags, NULL);
|
||||||
} else {
|
} else {
|
||||||
int errCode;
|
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;
|
std::string PathA;
|
||||||
PathA.resize(bufferSize);
|
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)
|
if (errCode == 0)
|
||||||
errCode = GetLastError();
|
errCode = GetLastError();
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
@ -168,7 +169,7 @@ bool WinIOCallback::open(const wchar_t* Path, const open_mode aMode, DWORD dwFla
|
|||||||
// Increase the buffer size
|
// Increase the buffer size
|
||||||
bufferSize += MAX_PATH;
|
bufferSize += MAX_PATH;
|
||||||
PathA.resize(bufferSize);
|
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)
|
if (errCode == 0)
|
||||||
errCode = GetLastError();
|
errCode = GetLastError();
|
||||||
}
|
}
|
||||||
@ -251,7 +252,7 @@ void WinIOCallback::setFilePointer(int64 Offset, seek_mode Mode)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mCurrentPosition |= uint64(High<<32);
|
mCurrentPosition |= uint64(High)<<32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user