[Bf-blender-cvs] [86b8c8a] master: Fix (unreported) possible freed memory usage when reloading a .blend file.

Bastien Montagne noreply at git.blender.org
Tue Apr 26 14:30:47 CEST 2016


Commit: 86b8c8a042ff118d4af461389ad081b71a9b12a8
Author: Bastien Montagne
Date:   Tue Apr 26 14:24:57 2016 +0200
Branches: master
https://developer.blender.org/rB86b8c8a042ff118d4af461389ad081b71a9b12a8

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.

===================================================================

M	source/blender/windowmanager/intern/wm_files.c

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 5e74eff..36b819d 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;




More information about the Bf-blender-cvs mailing list