diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2019-07-31 22:13:29 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2019-07-31 22:24:34 +0300 |
commit | ea3690e32974005c6ccb871f4e2f49471ad837ab (patch) | |
tree | d7145b6ed375599ee5534c5a1cd102012baf8150 | |
parent | 77d7cc9ba7a9c23c269cb89e8f6da9c800558973 (diff) |
Fix several undefined-behaviour-sanitizer warnings
Reviewers: brecht
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D4222
-rw-r--r-- | source/blender/blenkernel/intern/paint_toolslots.c | 15 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 15 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/depsgraph_tag.cc | 24 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_ops.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_text/space_text.c | 3 |
5 files changed, 44 insertions, 21 deletions
diff --git a/source/blender/blenkernel/intern/paint_toolslots.c b/source/blender/blenkernel/intern/paint_toolslots.c index fbf586e3f49..abaf5a96481 100644 --- a/source/blender/blenkernel/intern/paint_toolslots.c +++ b/source/blender/blenkernel/intern/paint_toolslots.c @@ -67,11 +67,16 @@ void BKE_paint_toolslots_init_from_main(struct Main *bmain) for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { ToolSettings *ts = scene->toolsettings; paint_toolslots_init(bmain, &ts->imapaint.paint); - paint_toolslots_init(bmain, &ts->sculpt->paint); - paint_toolslots_init(bmain, &ts->vpaint->paint); - paint_toolslots_init(bmain, &ts->wpaint->paint); - paint_toolslots_init(bmain, &ts->uvsculpt->paint); - paint_toolslots_init(bmain, &ts->gp_paint->paint); + if (ts->sculpt) + paint_toolslots_init(bmain, &ts->sculpt->paint); + if (ts->vpaint) + paint_toolslots_init(bmain, &ts->vpaint->paint); + if (ts->wpaint) + paint_toolslots_init(bmain, &ts->wpaint->paint); + if (ts->uvsculpt) + paint_toolslots_init(bmain, &ts->uvsculpt->paint); + if (ts->gp_paint) + paint_toolslots_init(bmain, &ts->gp_paint->paint); } } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index a4979cc470c..9f6db2264d9 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6413,12 +6413,17 @@ static void lib_link_scene(FileData *fd, Main *main) sce->set = newlibadr(fd, sce->id.lib, sce->set); sce->gpd = newlibadr_us(fd, sce->id.lib, sce->gpd); - link_paint(fd, sce, &sce->toolsettings->sculpt->paint); - link_paint(fd, sce, &sce->toolsettings->vpaint->paint); - link_paint(fd, sce, &sce->toolsettings->wpaint->paint); link_paint(fd, sce, &sce->toolsettings->imapaint.paint); - link_paint(fd, sce, &sce->toolsettings->uvsculpt->paint); - link_paint(fd, sce, &sce->toolsettings->gp_paint->paint); + if (sce->toolsettings->sculpt) + link_paint(fd, sce, &sce->toolsettings->sculpt->paint); + if (sce->toolsettings->vpaint) + link_paint(fd, sce, &sce->toolsettings->vpaint->paint); + if (sce->toolsettings->wpaint) + link_paint(fd, sce, &sce->toolsettings->wpaint->paint); + if (sce->toolsettings->uvsculpt) + link_paint(fd, sce, &sce->toolsettings->uvsculpt->paint); + if (sce->toolsettings->gp_paint) + link_paint(fd, sce, &sce->toolsettings->gp_paint->paint); if (sce->toolsettings->sculpt) { sce->toolsettings->sculpt->gravity_object = newlibadr( diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 59f0c8c1933..392514990e3 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -325,25 +325,31 @@ void deg_graph_id_tag_legacy_compat( * tagging here. */ case ID_ME: { Mesh *mesh = (Mesh *)id; - ID *key_id = &mesh->key->id; - if (key_id != NULL) { - graph_id_tag_update(bmain, depsgraph, key_id, 0, update_source); + if (mesh->key != NULL) { + ID *key_id = &mesh->key->id; + if (key_id != NULL) { + graph_id_tag_update(bmain, depsgraph, key_id, 0, update_source); + } } break; } case ID_LT: { Lattice *lattice = (Lattice *)id; - ID *key_id = &lattice->key->id; - if (key_id != NULL) { - graph_id_tag_update(bmain, depsgraph, key_id, 0, update_source); + if (lattice->key != NULL) { + ID *key_id = &lattice->key->id; + if (key_id != NULL) { + graph_id_tag_update(bmain, depsgraph, key_id, 0, update_source); + } } break; } case ID_CU: { Curve *curve = (Curve *)id; - ID *key_id = &curve->key->id; - if (key_id != NULL) { - graph_id_tag_update(bmain, depsgraph, key_id, 0, update_source); + if (curve->key != NULL) { + ID *key_id = &curve->key->id; + if (key_id != NULL) { + graph_id_tag_update(bmain, depsgraph, key_id, 0, update_source); + } } break; } diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index db4c601709c..d259bb9183c 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -81,9 +81,15 @@ static bool gp_stroke_paintmode_poll_with_tool(bContext *C, const char gpencil_t { /* TODO: limit this to mode, but review 2D editors */ bGPdata *gpd = CTX_data_gpencil_data(C); + if (!gpd) + return false; + ToolSettings *ts = CTX_data_tool_settings(C); + if (!ts || !ts->gp_paint) + return false; + Brush *brush = BKE_paint_brush(&ts->gp_paint->paint); - return ((gpd) && (gpd->flag & GP_DATA_STROKE_PAINTMODE) && (brush && brush->gpencil_settings) && + return ((gpd->flag & GP_DATA_STROKE_PAINTMODE) && (brush && brush->gpencil_settings) && WM_toolsystem_active_tool_is_brush(C) && (brush->gpencil_tool == gpencil_tool)); } diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 24f282ff920..70985bbb072 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -254,7 +254,8 @@ static int text_context(const bContext *C, const char *member, bContextDataResul return 1; } else if (CTX_data_equals(member, "edit_text")) { - CTX_data_id_pointer_set(result, &st->text->id); + if (st->text) + CTX_data_id_pointer_set(result, &st->text->id); return 1; } |