From: John Darrington Date: Sat, 4 May 2019 04:29:44 +0000 (+0200) Subject: EXAMINE: Don't crash when unrenderable graphs are requested. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=456b47421c16fdbbfe7f1e74e661d7c7876ff6df;p=pspp EXAMINE: Don't crash when unrenderable graphs are requested. This change fixes a crash in the cleanup of the cairo driver when a graph which is not representable was attempted to be rendered. --- diff --git a/src/output/charts/np-plot.c b/src/output/charts/np-plot.c index ccccbeff36..a140230e06 100644 --- a/src/output/charts/np-plot.c +++ b/src/output/charts/np-plot.c @@ -33,7 +33,7 @@ make_np_plot (const struct np *np, const struct casereader *reader, { struct np_plot_chart *npp; - if (np->n < 1.0) + if (np->n <= 1.0) return NULL; npp = xzalloc (sizeof *npp); diff --git a/src/output/driver.c b/src/output/driver.c index da448b3170..44aa255824 100644 --- a/src/output/driver.c +++ b/src/output/driver.c @@ -76,6 +76,8 @@ static struct output_engine * engine_stack_top (void) { struct ll *head = ll_head (&engine_stack); + if (ll_is_empty (head)) + return NULL; return ll_data (head, struct output_engine, ll); } @@ -202,6 +204,9 @@ output_submit (struct output_item *item) { struct output_engine *e = engine_stack_top (); + if (e == NULL) + return; + if (item == NULL) return; @@ -262,6 +267,9 @@ const char * output_get_command_name (void) { struct output_engine *e = engine_stack_top (); + if (e == NULL) + return NULL; + for (size_t i = e->n_groups; i-- > 0; ) if (e->groups[i]) return e->groups[i]; diff --git a/src/ui/terminal/main.c b/src/ui/terminal/main.c index 4609e4eded..c78756383a 100644 --- a/src/ui/terminal/main.c +++ b/src/ui/terminal/main.c @@ -160,13 +160,13 @@ main (int argc, char **argv) } + output_engine_pop (); session_destroy (the_session); random_done (); settings_done (); fh_done (); lex_destroy (lexer); - output_engine_pop (); i18n_done (); return msg_ui_any_errors (); diff --git a/tests/language/stats/examine.at b/tests/language/stats/examine.at index b2afe616b8..dbd11437fd 100644 --- a/tests/language/stats/examine.at +++ b/tests/language/stats/examine.at @@ -1,5 +1,5 @@ dnl PSPP - a program for statistical analysis. -dnl Copyright (C) 2017 Free Software Foundation, Inc. +dnl Copyright (C) 2017, 2019 Free Software Foundation, Inc. dnl dnl This program is free software: you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by @@ -1250,3 +1250,18 @@ Weight in kilograms ,Highest,1,13,92.1 ]) AT_CLEANUP + +AT_SETUP([EXAMINE -- Crash on unrepresentable graphs]) +AT_DATA([examine.sps], [dnl +data list notable list /x * g *. +begin data. +96 1 +end data. + +examine x by g + /nototal + /plot = all. +]) +dnl This bug only manifested itself on cairo based drivers. +AT_CHECK([pspp -O format=pdf examine.sps], [1], [ignore]) +AT_CLEANUP