Fix (unreported) possible freed memory usage when reloading a .blend file.

Operator would call `WM_file_read()` directly whith G.main->name as filepath, which
gets freed whith main during new reading of file... Now use a local copy instead.
This commit is contained in:
Bastien Montagne
2016-04-26 14:24:57 +02:00
parent 2a63ef03f0
commit 86b8c8a042

View File

@@ -1633,6 +1633,7 @@ void WM_OT_open_mainfile(wmOperatorType *ot)
static int wm_revert_mainfile_exec(bContext *C, wmOperator *op)
{
bool success;
char filepath[FILE_MAX];
wm_open_init_use_scripts(op, false);
@@ -1641,7 +1642,8 @@ static int wm_revert_mainfile_exec(bContext *C, wmOperator *op)
else
G.f &= ~G_SCRIPT_AUTOEXEC;
success = wm_file_read_opwrap(C, G.main->name, op->reports, !(G.f & G_SCRIPT_AUTOEXEC));
BLI_strncpy(filepath, G.main->name, sizeof(filepath));
success = wm_file_read_opwrap(C, filepath, op->reports, !(G.f & G_SCRIPT_AUTOEXEC));
if (success) {
return OPERATOR_FINISHED;