Page MenuHome

Undo with text editor and run script crashes blender
Closed, ResolvedPublic

Description

System Information
5820K GTX 970

Blender Version
Latest daily build

Short description of error
Text editor undo after run script can crash Blender

Crash line of code is in text.c - function txt_do_undo - line 2002
int op = text->undo_buf[text->undo_pos];

Reason looks to be that text->undo pos is negative here.

The test to check for a negative value is not made till later.

Possible code change....

int op;
int prev_flags;
unsigned int linep;
unsigned int uni_char;
unsigned int curln, selln;
unsigned short curc, selc;
unsigned short charp;
char *buf;
	
if (text->undo_pos < 0) {
	return;
}
op = text->undo_buf[text->undo_pos];

Exact steps for others to reproduce the error
Load file - press run script - do undo a couple of times

Details

Type
Bug

Event Timeline

Vuk Gardašević (lijenstina) renamed this task from Undo with text editor and runs cript crashes blender to Undo with text editor and run script crashes blender.Apr 2 2018, 7:40 PM
Philipp Oeser (lichtwerk) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.

Can confirm this [had to press "Run Script" twice before undo to trigger crash], suggested code change also makes sense at first sight, will doublecheck later...

Although I am sure the change will fix the crash. What I am unsure of (as I don't really know the code) is if calling the function txt_do_undo with text->undo_pos with a value of -1 is a code design feature of if it indicates something else is not right somewhere else.

This would be caused by recent undo restructuring, will look into it.