[Bf-blender-cvs] [9480ced] gooseberry: Avoid freeing and reading/writing NULL pointers. Should not happen often but better guard against it.
Antony Riakiotakis
noreply at git.blender.org
Tue Nov 4 14:49:13 CET 2014
Commit: 9480cede0f8ba34950c1472ef02d893ec0102661
Author: Antony Riakiotakis
Date: Tue Nov 4 14:48:33 2014 +0100
Branches: gooseberry
https://developer.blender.org/rB9480cede0f8ba34950c1472ef02d893ec0102661
Avoid freeing and reading/writing NULL pointers. Should not happen often
but better guard against it.
===================================================================
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/writefile.c
M source/blender/editors/space_view3d/space_view3d.c
===================================================================
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 1947307..d96c295 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6471,8 +6471,10 @@ static bool direct_link_screen(FileData *fd, bScreen *sc)
if (v3d->fxoptions) {
v3d->fxoptions = newdataadr(fd, v3d->fxoptions);
- v3d->fxoptions->dof_options = newdataadr(fd, v3d->fxoptions->dof_options);
- v3d->fxoptions->ssao_options = newdataadr(fd, v3d->fxoptions->ssao_options);
+ if (v3d->fxoptions->dof_options)
+ v3d->fxoptions->dof_options = newdataadr(fd, v3d->fxoptions->dof_options);
+ if (v3d->fxoptions->ssao_options)
+ v3d->fxoptions->ssao_options = newdataadr(fd, v3d->fxoptions->ssao_options);
}
blo_do_versions_view3d_split_250(v3d, &sl->regionbase);
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 14ed9ba..63a10c1 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2643,8 +2643,10 @@ static void write_screens(WriteData *wd, ListBase *scrbase)
if (v3d->localvd) writestruct(wd, DATA, "View3D", 1, v3d->localvd);
if (v3d->fxoptions) {
writestruct(wd, DATA, "GPUFXOptions", 1, v3d->fxoptions);
- writestruct(wd, DATA, "GPUDOFOptions", 1, v3d->fxoptions->dof_options);
- writestruct(wd, DATA, "GPUSSAOOptions", 1, v3d->fxoptions->ssao_options);
+ if (v3d->fxoptions->dof_options)
+ writestruct(wd, DATA, "GPUDOFOptions", 1, v3d->fxoptions->dof_options);
+ if (v3d->fxoptions->ssao_options)
+ writestruct(wd, DATA, "GPUSSAOOptions", 1, v3d->fxoptions->ssao_options);
}
}
else if (sl->spacetype==SPACE_IPO) {
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 7c4695c..7247d51 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -423,8 +423,10 @@ static void view3d_free(SpaceLink *sl)
if (vd->fxoptions) {
MEM_freeN(vd->fxoptions->dof_options);
- MEM_freeN(vd->fxoptions->ssao_options);
- MEM_freeN(vd->fxoptions);
+ if (vd->fxoptions->ssao_options)
+ MEM_freeN(vd->fxoptions->ssao_options);
+ if (vd->fxoptions->dof_options)
+ MEM_freeN(vd->fxoptions);
}
}
More information about the Bf-blender-cvs
mailing list