|
1 | 1 | /* Hello, Emacs: this is -*-C-*- !
|
2 |
| - * $Id: cairo.trm,v 1.79 2017-05-07 19:20:52 sfeam Exp $ |
| 2 | + * $Id: cairo.trm,v 1.80 2017-09-19 20:15:10 sfeam Exp $ |
3 | 3 | */
|
4 | 4 |
|
5 | 5 | /* GNUPLOT - cairo.trm */
|
@@ -653,16 +653,16 @@ void cairotrm_init()
|
653 | 653 | if (ISCAIROLATEX && !outstr)
|
654 | 654 | os_error(c_token, "cairolatex terminal cannot write to standard output");
|
655 | 655 |
|
| 656 | + /* We no longer do this in cairotrm_reset() */ |
| 657 | + if (plot.cr) |
| 658 | + cairo_destroy(plot.cr); |
| 659 | + |
656 | 660 | /* initialisations */
|
657 | 661 | gp_cairo_initialize_plot(&plot);
|
658 | 662 | plot.device_xmax = (double) cairo_params->width;
|
659 | 663 | plot.device_ymax = (double) cairo_params->height;
|
660 | 664 | plot.dashlength = cairo_params->dash_length;
|
661 | 665 |
|
662 |
| - /* is supposed to be done in cairotrm_reset */ |
663 |
| - if ( plot.cr ) |
664 |
| - cairo_destroy(plot.cr); |
665 |
| - |
666 | 666 | if (!strcmp(term->name,"pdfcairo")) {
|
667 | 667 | /* Output can either be a file or stdout */
|
668 | 668 | #ifndef _WIN32
|
@@ -973,8 +973,13 @@ void cairotrm_text()
|
973 | 973 | /* sent when gnuplot exits and when the terminal or the output change.*/
|
974 | 974 | void cairotrm_reset()
|
975 | 975 | {
|
976 |
| - /* finish the document */ |
977 |
| - cairo_destroy(plot.cr); |
| 976 | + /* Sep 2017 |
| 977 | + * valgrind complains that this triggers reads of already-freed data. |
| 978 | + * It is unclear whether that is a real problem, but it is also unclear |
| 979 | + * that anything is gained by explicit cleanup when we are about to exit. |
| 980 | + * Let's try skipping it and see if anyone notices. |
| 981 | + */ |
| 982 | + /* cairo_destroy(plot.cr); */ |
978 | 983 |
|
979 | 984 | #ifdef PSLATEX_DRIVER
|
980 | 985 | /* finish latex output */
|
|
0 commit comments