[Bf-blender-cvs] [60663c8] master: Fix various potential bugs from coverity reports (NULL dereference, negative number assigned to uint...).

Bastien Montagne noreply at git.blender.org
Mon Jan 25 16:56:42 CET 2016


Commit: 60663c8ec42f1cf0f527a42ea3c6ebbd9b4d3153
Author: Bastien Montagne
Date:   Mon Jan 25 16:55:08 2016 +0100
Branches: master
https://developer.blender.org/rB60663c8ec42f1cf0f527a42ea3c6ebbd9b4d3153

Fix various potential bugs from coverity reports (NULL dereference, negative number assigned to uint...).

Note: the wm_jobs needs proper fix, we cannot have that kind of inconsistencies in some 'public' API!

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

M	source/blender/blenkernel/intern/object_deform.c
M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/windowmanager/intern/wm_jobs.c

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

diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c
index 38391c8..b5f6358 100644
--- a/source/blender/blenkernel/intern/object_deform.c
+++ b/source/blender/blenkernel/intern/object_deform.c
@@ -604,7 +604,8 @@ void BKE_object_defgroup_mirror_selection(
         bool *dg_flags_sel, int *r_dg_flags_sel_tot)
 {
 	bDeformGroup *defgroup;
-	unsigned int i, i_mirr;
+	unsigned int i;
+	int i_mirr;
 
 	for (i = 0, defgroup = ob->defbase.first; i < defbase_tot && defgroup; defgroup = defgroup->next, i++) {
 		if (dg_selection[i]) {
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 2ba0797..e4e9976 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -168,7 +168,7 @@ static void load_tex_task_cb_ex(void *userdata, void *UNUSED(userdata_chunck), c
 	bool convert_to_linear = false;
 	struct ColorSpace *colorspace = NULL;
 
-	if (mtex->tex->type == TEX_IMAGE && mtex->tex->ima) {
+	if (mtex->tex && mtex->tex->type == TEX_IMAGE && mtex->tex->ima) {
 		ImBuf *tex_ibuf = BKE_image_pool_acquire_ibuf(mtex->tex->ima, &mtex->tex->iuser, pool);
 		/* For consistency, sampling always returns color in linear space */
 		if (tex_ibuf && tex_ibuf->rect_float == NULL) {
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index f90df4b..f245685 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -2081,9 +2081,6 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
 	bool use_face_sel;
 	bool use_depth;
 
-	float (*blur_weight_func)(MDeformVert *, WeightPaintInfo *) =
-	        wpd->do_multipaint ? wpaint_blur_weight_multi : wpaint_blur_weight_single;
-
 	const float pressure = RNA_float_get(itemptr, "pressure");
 	const float brush_size_pressure =
 	        BKE_brush_size_get(scene, brush) * (BKE_brush_use_size_pressure(scene, brush) ? pressure : 1.0f);
@@ -2102,6 +2099,9 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
 		return;
 	}
 
+	float (*blur_weight_func)(MDeformVert *, WeightPaintInfo *) =
+	        wpd->do_multipaint ? wpaint_blur_weight_multi : wpaint_blur_weight_single;
+
 	vc = &wpd->vc;
 	ob = vc->obact;
 	me = ob->data;
diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c
index 19b393b..e445de2 100644
--- a/source/blender/windowmanager/intern/wm_jobs.c
+++ b/source/blender/windowmanager/intern/wm_jobs.c
@@ -294,7 +294,7 @@ bool WM_jobs_is_running(wmJob *wm_job)
 bool WM_jobs_is_stopped(wmWindowManager *wm, void *owner)
 {
 	wmJob *wm_job = wm_job_find(wm, owner, WM_JOB_TYPE_ANY);
-	return wm_job->stop;
+	return wm_job ? wm_job->stop : true; /* XXX to be redesigned properly. */
 }
 
 void *WM_jobs_customdata_get(wmJob *wm_job)




More information about the Bf-blender-cvs mailing list