From: Ben Pfaff Date: Sat, 20 Feb 2010 19:11:18 +0000 (-0800) Subject: NPAR TESTS: Avoid segfault in do_summary_box() if descriptives disabled. X-Git-Tag: v0.7.5~139 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32b1cdd68664c94211ff4427f68f8247b6c7941a;p=pspp-builds.git NPAR TESTS: Avoid segfault in do_summary_box() if descriptives disabled. Found by Clang (http://clang-analyzer.llvm.org). --- diff --git a/src/language/stats/npar-summary.c b/src/language/stats/npar-summary.c index 05fa1d02..62529136 100644 --- a/src/language/stats/npar-summary.c +++ b/src/language/stats/npar-summary.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2009, 2010 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 @@ -160,11 +160,15 @@ do_summary_box (const struct descriptives *desc, tab_text (table, 0, 2 + v, 0, var_to_string (var)); - tab_double (table, 1, 2 + v, 0, desc[v].n, fmt); - tab_double (table, 2, 2 + v, 0, desc[v].mean, fmt); - tab_double (table, 3, 2 + v, 0, desc[v].std_dev, fmt); - tab_double (table, 4, 2 + v, 0, desc[v].min, fmt); - tab_double (table, 5, 2 + v, 0, desc[v].max, fmt); + col = 1; + if (desc != NULL) + { + tab_double (table, col++, 2 + v, 0, desc[v].n, fmt); + tab_double (table, col++, 2 + v, 0, desc[v].mean, fmt); + tab_double (table, col++, 2 + v, 0, desc[v].std_dev, fmt); + tab_double (table, col++, 2 + v, 0, desc[v].min, fmt); + tab_double (table, col++, 2 + v, 0, desc[v].max, fmt); + } }