From: Ben Pfaff Date: Thu, 2 Jul 2009 03:50:33 +0000 (-0700) Subject: chart: Fix format string issues in chart_write_title callers. X-Git-Tag: v0.7.3~12 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62120c1a218f5172d69357073297a1004ec9ee52;p=pspp-builds.git chart: Fix format string issues in chart_write_title callers. The 'title' argument to chart_write_title is used as a printf-type format string, so callers must pass "%s" to safely use an arbitrary string as a title. --- diff --git a/src/language/stats/examine.q b/src/language/stats/examine.q index 99ff5c45..f3fec17b 100644 --- a/src/language/stats/examine.q +++ b/src/language/stats/examine.q @@ -609,7 +609,7 @@ show_boxplot_variables (const struct variable **dependent_var, var_append_value_name (fctr->indep_var[0], &result->value[0], &title); #endif - chart_write_title (ch, ds_cstr (&title)); + chart_write_title (ch, "%s", ds_cstr (&title)); ds_destroy (&title); for (v = 0; v < n_dep_var; ++v) diff --git a/src/output/charts/barchart.c b/src/output/charts/barchart.c index 88a1d741..96cd07fb 100644 --- a/src/output/charts/barchart.c +++ b/src/output/charts/barchart.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -202,7 +202,7 @@ draw_barchart(struct chart *ch, const char *title, pl_restorestate_r(ch->lp); - chart_write_title(ch, title); + chart_write_title(ch, "%s", title); write_legend(ch); diff --git a/src/output/charts/piechart.c b/src/output/charts/piechart.c index 869f21b2..97910010 100644 --- a/src/output/charts/piechart.c +++ b/src/output/charts/piechart.c @@ -69,7 +69,7 @@ piechart_plot(const char *title, const struct slice *slices, int n_slices) double angle; - chart_write_title(ch, title); + chart_write_title(ch, "%s", title); for (i = 0 ; i < n_slices ; ++i ) total_magnitude += slices[i].magnitude; diff --git a/src/output/charts/plot-chart.h b/src/output/charts/plot-chart.h index 4a1dc105..f29b4a35 100644 --- a/src/output/charts/plot-chart.h +++ b/src/output/charts/plot-chart.h @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -55,7 +56,8 @@ void draw_tick(struct chart *chart, /* Write the title on a chart*/ -void chart_write_title(struct chart *chart, const char *title, ...); +void chart_write_title(struct chart *chart, const char *title, ...) + PRINTF_FORMAT (2, 3); /* Set the scale for the abscissa */