Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2016-04-26 15:24:57 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2016-04-26 15:27:32 +0300
commit86b8c8a042ff118d4af461389ad081b71a9b12a8 (patch)
tree7bdf2aadf9f0e1d8a857013403c9d51f0a6fcd5f
parent2a63ef03f041cb02202f3be03b92abc11848b51c (diff)
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.
-rw-r--r--source/blender/windowmanager/intern/wm_files.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 5e74eff645d..36b819d3495 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -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;