Chris7 / Mudlet2

Mudlet vesion 2.+
GNU General Public License v2.0
3 stars 2 forks source link

Crash in main window on double-click #6

Closed vadi2 closed 11 years ago

vadi2 commented 11 years ago

When you double-click on the space in a line that has no text, a crash happens. See this video for a demo: http://ge.tt/5Irsvuj/v/0

I've did some work to dig about and narrowed it down to this commit: https://github.com/Chris7/Mudlet2/commit/60f248b920a84911babaaa13e01aef154c9a12d1

The issue in question is the line QString c = mpBuffer->lineBuffer[yind].at(xind);, in which the at() function will cause a crash: xind tries to access a part of the line that doesn't have any text on it. See two screenshots that demonstrating this - notice how line 44 is just "" and it tries to do .at(26), which is invalid.

selection_364

selection_365

Chris7 commented 11 years ago

Fixed in mudletDev branch.

vadi2 commented 11 years ago

Does the buffer count from 0? If it does, the patch would be susceptible to an off-by-one error:

            if ( yind > mpBuffer->lineBuffer.size() )
                return;

yind = 2 lineBuffer.size() = 2 (so 0 and 1 are the valid indexes)

if ( 2 > 2 ) (false!)
   return;   (won't return!)
Chris7 commented 11 years ago

Maybe. Repushed a version that accounts for that.