Fix crash w/ empty text undo operations

This commit is contained in:
Campbell Barton 2018-04-05 09:59:21 +02:00
parent d59c2d12b1
commit 47b6e23271
Notes: blender-bot 2023-02-14 06:04:15 +01:00
Referenced by issue #54494, Undo with text editor and run script crashes blender
1 changed files with 9 additions and 3 deletions

View File

@ -90,11 +90,17 @@ static bool text_undosys_poll(bContext *C)
static bool text_undosys_step_encode(struct bContext *C, UndoStep *us_p)
{
TextUndoStep *us = (TextUndoStep *)us_p;
Text *text = CTX_data_edit_text(C);
us->text_ref.ptr = text;
BLI_assert(BLI_array_is_zeroed(&us->data, 1));
Text *text = CTX_data_edit_text(C);
/* No undo data was generated. Hint, use global undo here. */
if (text->undo_pos == -1) {
return false;
}
us->text_ref.ptr = text;
us->data.buf = text->undo_buf;
us->data.pos = text->undo_pos;
us->data.len = text->undo_len;