Commit 9f845a0c39fa412683e27b9c80124c5e656dd396
1 parent
a9e1073e
Avoid illegal memory access in GLog::append().
On Mac OS X I encountered some KERN_INVALID_ADDRESS problems in the GLog::append() method. A possible reason to this was the test of the value of m_buffer[m_buffer.size()-1] without checking whether m_buffer.size() was positive. I added the test, hopefully the KERN_INVALID_ADDRESS problem (which was spurious) goes away.
Showing
1 changed file
with
3 additions
and
3 deletions
src/app/GLog.cpp
| ... | ... | @@ -777,10 +777,10 @@ std::string GLog::prefix(void) const |
| 777 | 777 | void GLog::append(std::string arg) |
| 778 | 778 | { |
| 779 | 779 | // If the buffer is empty and at the beginning of a line or if the last |
| 780 | - // charater is a \n, prepend a prefix at the beginning of the string to | |
| 781 | - // be inserted. | |
| 780 | + // character is a \n then prepend a prefix at the beginning of the string | |
| 781 | + // to be inserted. | |
| 782 | 782 | if ((m_buffer.size() == 0 && m_linestart) || |
| 783 | - m_buffer[m_buffer.size()-1] == '\n') { | |
| 783 | + (m_buffer.size() > 0 && m_buffer[m_buffer.size()-1] == '\n')) { | |
| 784 | 784 | |
| 785 | 785 | // Prepend prefix |
| 786 | 786 | arg.insert(0, prefix()); | ... | ... |