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
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2010-03-27 13:43:04 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2010-03-27 13:43:04 +0300
commit91d56f8a6d684838a51d14149302529518a0805a (patch)
tree1b64d05a9012144a37b15dd41c3ab02fc7650978 /source
parenta5197f4943a2c117a53b50ca12eba193d42663ea (diff)
Check result of object_add_duplicate_internal() before using it.
This prevents segmentation fault when object in pose mode is duplicating.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/object/object_add.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index a2070771844..fd2509cbfda 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1709,13 +1709,17 @@ Base *ED_object_add_duplicate(Scene *scene, Base *base, int dupflag)
clear_id_newpoins();
clear_sca_new_poins(); /* sensor/contr/act */
-
+
basen= object_add_duplicate_internal(scene, base, dupflag);
+ if (basen == NULL) {
+ return NULL;
+ }
+
ob= basen->object;
-
+
DAG_scene_sort(scene);
ED_render_id_flush_update(G.main, ob->data);
-
+
return basen;
}
@@ -1736,6 +1740,10 @@ static int duplicate_exec(bContext *C, wmOperator *op)
the list is made in advance */
ED_base_object_select(base, BA_DESELECT);
+ if (basen == NULL) {
+ continue;
+ }
+
/* new object becomes active */
if(BASACT==base)
ED_base_object_activate(C, basen);
@@ -1798,36 +1806,42 @@ static int add_named_exec(bContext *C, wmOperator *op)
int linked= RNA_boolean_get(op->ptr, "linked");
int dupflag= (linked)? 0: U.dupflag;
char name[32];
-
+
/* find object, create fake base */
RNA_string_get(op->ptr, "name", name);
ob= (Object *)find_id("OB", name);
if(ob==NULL)
return OPERATOR_CANCELLED;
-
+
base= MEM_callocN(sizeof(Base), "duplibase");
base->object= ob;
base->flag= ob->flag;
-
+
/* prepare dupli */
clear_id_newpoins();
clear_sca_new_poins(); /* sensor/contr/act */
-
+
basen= object_add_duplicate_internal(scene, base, dupflag);
+
+ if (basen == NULL) {
+ MEM_freeN(base);
+ return OPERATOR_CANCELLED;
+ }
+
basen->lay= basen->object->lay= scene->lay;
-
+
ED_object_location_from_view(C, basen->object->loc);
ED_base_object_activate(C, basen);
-
+
copy_object_set_idnew(C, dupflag);
-
+
DAG_scene_sort(scene);
DAG_ids_flush_update(0);
-
+
MEM_freeN(base);
-
+
WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
-
+
return OPERATOR_FINISHED;
}