Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#2028 closed defect (fixed)

[BUG] CInput::UpdateText() crash in Debug build

Reported by: Jorma Rebane Owned by: Jorma Rebane
Priority: Must Have Milestone: Alpha 14
Component: Core engine Keywords: patch defect
Cc: Patch:

Description

In VC++11.0 or higher, CInput::UpdateText() will crash in debug build with error: Iterators incompatible.

This is due to std::list<SRow>::erase invalidating the iterators and no code to update the active iterators.

The actual fix is very simple.

Previously the code relied on undefined behavior to run.

Attachments (1)

CInput_iterators.patch (1.7 KB ) - added by Jorma Rebane 11 years ago.
Less hacky fix

Download all attachments as: .zip

Change History (5)

comment:1 by historic_bruno, 11 years ago

Could we do this:

current_line = m_CharacterPositions.erase(destroy_row_from, destroy_row_to);

instead of setting current_line before the erase? That should always be the correct, valid iterator? (it also fixes the assertion failure)

by Jorma Rebane, 11 years ago

Attachment: CInput_iterators.patch added

Less hacky fix

in reply to:  1 comment:2 by Jorma Rebane, 11 years ago

Replying to historic_bruno:

Could we do this:

current_line = m_CharacterPositions.erase(destroy_row_from, destroy_row_to);

instead of setting current_line before the erase? That should always be the correct, valid iterator? (it also fixes the assertion failure)

Changed and tested. Works exactly the same. New patch file added with the one-liner.

comment:3 by leper, 11 years ago

Resolution: fixed
Status: newclosed

In 13539:

Fix crash in VC++11 debug builds. Fixes #2028. Patch by RedFox.

comment:4 by leper, 11 years ago

Keywords: review removed

Thanks.

Note: See TracTickets for help on using tickets.