This patch fixes Use After Free and Uninitialized Read errors in FileManager and Utf8_16_Read.
Solution is highly not elegant but it's much better than having UAF errors in code.
1) Use After Free bug in FileManager::loadFile () and FileManager::reloadBuffer():
First, in FileManager::loadFile () we are creating Utf8_16_Read UnicodeConvertor object. Then we are passing it into FileManager::loadFileData().
After that char data buffer is created inside of FileManager::loadFileData() and passed to UnicodeConvertor.convert().
Inside of UnicodeConvertor.convert(). pointer to buffer is stored to m_Buf and m_NewBuf.
When FileManager::loadFileData() is done, buffer is destroyed. m_Buf and m_NewBuf are now pointing to unallocated memory that probably still have our data (until we will allocate something).
Then we are using UnicodeConvertor.getNewBuf() and reading unallocated memory.
2) Possible read out-of-bounds bug in FileManager::getEOLFormatForm()
Since UnicodeConvertor.getNewBuf() is not considered to be NULL-terminated, we cant use strlen() on it.
3) Fixes for using unitialized variables in FileManager and Utf8_16_Read.
Tested on win7 x64.
I request other developers to test this changes.
All bugs detected with Dr. Memory tool.