File fix4bug1240325.patch of Package gnuplot.38683
commit b456a3ef618f55a20b3071d336cb20514274f1d4
Author: Ethan A Merritt <merritt@u.washington.edu>
Date: Tue Mar 11 12:31:54 2025 -0700
guard against invalid read from plot->labels
If a plot style uses points and the point chosen has PT_CHARACTER
then the program looks for a possible font in plot->labels->font.
These plot styles contain a flag bit HAS_POINT (gp_types.h).
The program makes sure to initialize plot->labels for these styles.
However a problem arises when a plot style that doesn't use points
nevertheless triggers this same attempted font lookup by using a
linetype that happens to use pointtype PT_CHARACTER.
I think this is only possible with 'splot' but I added parallel
checks for 'plot' as well.
Bug 2776
---
src/boundary.c | 2 +-
src/graph3d.c | 4 ++--
src/graphics.c | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
--- src/boundary.c
+++ src/boundary.c 2025-05-13 10:41:46.572260645 +0000
@@ -1440,7 +1440,7 @@ do_key_sample_point(
(*t->pointsize)(pointsize);
if (on_page(xl + key_point_offset, yl)) {
if (this_plot->lp_properties.p_type == PT_CHARACTER) {
- if (this_plot->labels->textcolor.type != TC_DEFAULT)
+ if (this_plot->labels && this_plot->labels->textcolor.type != TC_DEFAULT)
apply_pm3dcolor(&(this_plot->labels->textcolor));
(*t->put_text) (xl + key_point_offset, yl,
this_plot->lp_properties.p_char);
--- src/graph3d.c
+++ src/graph3d.c 2025-05-13 10:34:47.791935885 +0000
@@ -2016,7 +2016,7 @@ plot3d_points(struct surface_points *plo
/* Set whatever we can that applies to every point in the loop */
if (plot->lp_properties.p_type == PT_CHARACTER) {
ignore_enhanced(TRUE);
- if (plot->labels->font && plot->labels->font[0])
+ if (plot->labels && plot->labels->font && plot->labels->font[0])
(*t->set_font) (plot->labels->font);
(*t->justify_text) (CENTRE);
}
@@ -2111,7 +2111,7 @@ plot3d_points(struct surface_points *plo
/* Return to initial state */
if (plot->lp_properties.p_type == PT_CHARACTER) {
- if (plot->labels->font && plot->labels->font[0])
+ if (plot->labels && plot->labels->font && plot->labels->font[0])
(*t->set_font) ("");
ignore_enhanced(FALSE);
}
--- src/graphics.c
+++ src/graphics.c 2025-05-13 10:34:47.867934492 +0000
@@ -2353,7 +2353,7 @@ plot_points(struct curve_points *plot)
/* Set whatever we can that applies to every point in the loop */
if (plot->lp_properties.p_type == PT_CHARACTER) {
ignore_enhanced(TRUE);
- if (plot->labels->font && plot->labels->font[0])
+ if (plot->labels && plot->labels->font && plot->labels->font[0])
(*t->set_font) (plot->labels->font);
(*t->justify_text) (CENTRE);
}
@@ -2475,7 +2475,7 @@ plot_points(struct curve_points *plot)
/* Return to initial state */
if (plot->lp_properties.p_type == PT_CHARACTER) {
- if (plot->labels->font && plot->labels->font[0])
+ if (plot->labels && plot->labels->font && plot->labels->font[0])
(*t->set_font) ("");
ignore_enhanced(FALSE);
}