From 96eb1618deb9a5777da28926823c22a188253e70 Mon Sep 17 00:00:00 2001 From: Shubham Vasudeo Desai Date: Sun, 3 Nov 2024 14:57:50 -0500 Subject: [PATCH 1/7] Dereference after Null Check --- display/d.vect/lines.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/display/d.vect/lines.c b/display/d.vect/lines.c index 69bac799e5e..b272075e41b 100644 --- a/display/d.vect/lines.c +++ b/display/d.vect/lines.c @@ -334,14 +334,20 @@ int draw_line(int type, int ltype, int line, const struct line_pnts *Points, /* use random or RGB column color if given, otherwise reset */ /* centroids always use default color to stand out from underlying area */ - if (custom_rgb && (ltype != GV_CENTROID)) { - primary_color->r = (unsigned char)red; - primary_color->g = (unsigned char)grn; - primary_color->b = (unsigned char)blu; - D_symbol2(Symb, x0, y0, primary_color, line_color); + if (Symb) { + if (custom_rgb && (ltype != GV_CENTROID)) { + primary_color->r = (unsigned char)red; + primary_color->g = (unsigned char)grn; + primary_color->b = (unsigned char)blu; + D_symbol2(Symb, x0, y0, primary_color, line_color); + } + else { + D_symbol(Symb, x0, y0, line_color, fill_color); + } + } + else { + G_warning(_("Symbol is NULL; unable to display points")); } - else - D_symbol(Symb, x0, y0, line_color, fill_color); /* reset to defaults */ var_size = size; From 38b95c615a44493e85900f48ed93b8a7327d1c36 Mon Sep 17 00:00:00 2001 From: ShubhamDesai <42180509+ShubhamDesai@users.noreply.github.com> Date: Sun, 3 Nov 2024 15:07:14 -0500 Subject: [PATCH 2/7] Update display/d.vect/lines.c Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- display/d.vect/lines.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/display/d.vect/lines.c b/display/d.vect/lines.c index b272075e41b..0ec5381f55f 100644 --- a/display/d.vect/lines.c +++ b/display/d.vect/lines.c @@ -343,7 +343,7 @@ int draw_line(int type, int ltype, int line, const struct line_pnts *Points, } else { D_symbol(Symb, x0, y0, line_color, fill_color); - } + } } else { G_warning(_("Symbol is NULL; unable to display points")); From c466361c9663e48a7b0ba34cd35cb78c562e5d94 Mon Sep 17 00:00:00 2001 From: Shubham Vasudeo Desai Date: Sun, 1 Dec 2024 21:14:29 -0500 Subject: [PATCH 3/7] Changes Requested --- display/d.vect/lines.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/display/d.vect/lines.c b/display/d.vect/lines.c index b272075e41b..26066be03ce 100644 --- a/display/d.vect/lines.c +++ b/display/d.vect/lines.c @@ -345,30 +345,28 @@ int draw_line(int type, int ltype, int line, const struct line_pnts *Points, D_symbol(Symb, x0, y0, line_color, fill_color); } } - else { - G_warning(_("Symbol is NULL; unable to display points")); - } - /* reset to defaults */ var_size = size; rotation = 0.0; } else if (color || custom_rgb || zcolors) { - if (!cvarr_rgb && !cats_color_flag && !zcolors && !colors) - D_RGB_color(color->r, color->g, color->b); - else { - if (custom_rgb) - D_RGB_color((unsigned char)red, (unsigned char)grn, - (unsigned char)blu); - else + if (color) { + if (!cvarr_rgb && !cats_color_flag && !zcolors && !colors) D_RGB_color(color->r, color->g, color->b); - } + else { + if (custom_rgb) + D_RGB_color((unsigned char)red, (unsigned char)grn, + (unsigned char)blu); + else + D_RGB_color(color->r, color->g, color->b); + } - /* Plot the lines */ - if (Points->n_points == 1) /* line with one coor */ - D_polydots_abs(x, y, Points->n_points); - else /* use different user defined render methods */ - D_polyline_abs(x, y, Points->n_points); + /* Plot the lines */ + if (Points->n_points == 1) /* line with one coor */ + D_polydots_abs(x, y, Points->n_points); + else /* use different user defined render methods */ + D_polyline_abs(x, y, Points->n_points); + } } switch (ltype) { @@ -391,5 +389,6 @@ int draw_line(int type, int ltype, int line, const struct line_pnts *Points, break; } + G_free(Symb); return 1; } From dc93beee6232fff02581900447deb5a7a0567fe0 Mon Sep 17 00:00:00 2001 From: ShubhamDesai <42180509+ShubhamDesai@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:20:28 -0500 Subject: [PATCH 4/7] Update display/d.vect/lines.c Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- display/d.vect/lines.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/display/d.vect/lines.c b/display/d.vect/lines.c index 4f53e2bbbe2..61740859bc1 100644 --- a/display/d.vect/lines.c +++ b/display/d.vect/lines.c @@ -356,7 +356,7 @@ int draw_line(int type, int ltype, int line, const struct line_pnts *Points, else { if (custom_rgb) D_RGB_color((unsigned char)red, (unsigned char)grn, - (unsigned char)blu); + (unsigned char)blu); else D_RGB_color(color->r, color->g, color->b); } From 9200ed7405792892486d487015f14343d51461c8 Mon Sep 17 00:00:00 2001 From: ShubhamDesai <42180509+ShubhamDesai@users.noreply.github.com> Date: Sun, 1 Dec 2024 21:20:35 -0500 Subject: [PATCH 5/7] Update display/d.vect/lines.c Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- display/d.vect/lines.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/display/d.vect/lines.c b/display/d.vect/lines.c index 61740859bc1..127e4a529e5 100644 --- a/display/d.vect/lines.c +++ b/display/d.vect/lines.c @@ -366,7 +366,7 @@ int draw_line(int type, int ltype, int line, const struct line_pnts *Points, D_polydots_abs(x, y, Points->n_points); else /* use different user defined render methods */ D_polyline_abs(x, y, Points->n_points); - } + } } switch (ltype) { From 02aa9ae5611f4e683f8bf5ed52eaeef5d89442f2 Mon Sep 17 00:00:00 2001 From: Shubham Vasudeo Desai Date: Mon, 23 Dec 2024 05:08:54 -0500 Subject: [PATCH 6/7] Fix colors with default --- display/d.vect/lines.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/display/d.vect/lines.c b/display/d.vect/lines.c index 4f53e2bbbe2..a3a0116991a 100644 --- a/display/d.vect/lines.c +++ b/display/d.vect/lines.c @@ -350,23 +350,25 @@ int draw_line(int type, int ltype, int line, const struct line_pnts *Points, rotation = 0.0; } else if (color || custom_rgb || zcolors) { - if (color) { - if (!cvarr_rgb && !cats_color_flag && !zcolors && !colors) - D_RGB_color(color->r, color->g, color->b); - else { - if (custom_rgb) - D_RGB_color((unsigned char)red, (unsigned char)grn, + if (!color) { + G_warning("Color is null, assigning light gray."); + D_RGB_color(198, 198, 198); + } + else if (!cvarr_rgb && !cats_color_flag && !zcolors && !colors) + D_RGB_color(color->r, color->g, color->b); + else { + if (custom_rgb) + D_RGB_color((unsigned char)red, (unsigned char)grn, (unsigned char)blu); - else - D_RGB_color(color->r, color->g, color->b); + else + D_RGB_color(color->r, color->g, color->b); } - /* Plot the lines */ - if (Points->n_points == 1) /* line with one coor */ - D_polydots_abs(x, y, Points->n_points); - else /* use different user defined render methods */ - D_polyline_abs(x, y, Points->n_points); - } + /* Plot the lines */ + if (Points->n_points == 1) /* line with one coor */ + D_polydots_abs(x, y, Points->n_points); + else /* use different user defined render methods */ + D_polyline_abs(x, y, Points->n_points); } switch (ltype) { From 98bb296d70ea2226a24f9bf7f03ff6164aa2bbc2 Mon Sep 17 00:00:00 2001 From: Shubham Vasudeo Desai Date: Mon, 23 Dec 2024 05:20:48 -0500 Subject: [PATCH 7/7] Formatting --- display/d.vect/lines.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/display/d.vect/lines.c b/display/d.vect/lines.c index a3a0116991a..3fcd042603c 100644 --- a/display/d.vect/lines.c +++ b/display/d.vect/lines.c @@ -353,7 +353,7 @@ int draw_line(int type, int ltype, int line, const struct line_pnts *Points, if (!color) { G_warning("Color is null, assigning light gray."); D_RGB_color(198, 198, 198); - } + } else if (!cvarr_rgb && !cats_color_flag && !zcolors && !colors) D_RGB_color(color->r, color->g, color->b); else { @@ -362,13 +362,13 @@ int draw_line(int type, int ltype, int line, const struct line_pnts *Points, (unsigned char)blu); else D_RGB_color(color->r, color->g, color->b); - } + } /* Plot the lines */ if (Points->n_points == 1) /* line with one coor */ D_polydots_abs(x, y, Points->n_points); else /* use different user defined render methods */ - D_polyline_abs(x, y, Points->n_points); + D_polyline_abs(x, y, Points->n_points); } switch (ltype) {