Fixed a crash bug in stb_textedit.h (#681)

This commit is contained in:
ocornut 2016-06-04 14:48:08 +01:00
parent 8291d7dc7c
commit 0f36ec9cb9

View File

@ -1,4 +1,5 @@
// [ImGui] this is a slightly modified version of stb_truetype.h 1.8 // [ImGui] this is a slightly modified version of stb_truetype.h 1.8
// [ImGui] - fixed a crash bug in stb_textedit_discard_redo (#681)
// [ImGui] - fixed some minor warnings // [ImGui] - fixed some minor warnings
// [ImGui] - added STB_TEXTEDIT_MOVEWORDLEFT/STB_TEXTEDIT_MOVEWORDRIGHT custom handler (#473) // [ImGui] - added STB_TEXTEDIT_MOVEWORDLEFT/STB_TEXTEDIT_MOVEWORDRIGHT custom handler (#473)
@ -1095,7 +1096,7 @@ static void stb_textedit_discard_redo(StbUndoState *state)
int n = state->undo_rec[k].insert_length, i; int n = state->undo_rec[k].insert_length, i;
// delete n characters from all other records // delete n characters from all other records
state->redo_char_point = state->redo_char_point + (short) n; // vsnet05 state->redo_char_point = state->redo_char_point + (short) n; // vsnet05
STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((size_t)(STB_TEXTEDIT_UNDOSTATECOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE))); STB_TEXTEDIT_memmove(state->undo_char + state->redo_char_point, state->undo_char + state->redo_char_point-n, (size_t) ((size_t)(STB_TEXTEDIT_UNDOCHARCOUNT - state->redo_char_point)*sizeof(STB_TEXTEDIT_CHARTYPE)));
for (i=state->redo_point; i < k; ++i) for (i=state->redo_point; i < k; ++i)
if (state->undo_rec[i].char_storage >= 0) if (state->undo_rec[i].char_storage >= 0)
state->undo_rec[i].char_storage = state->undo_rec[i].char_storage + (short) n; // vsnet05 state->undo_rec[i].char_storage = state->undo_rec[i].char_storage + (short) n; // vsnet05