Fixed bug #11675
authorJohn Darrington <john@darrington.wattle.id.au>
Tue, 25 Jan 2005 13:04:46 +0000 (13:04 +0000)
committerJohn Darrington <john@darrington.wattle.id.au>
Tue, 25 Jan 2005 13:04:46 +0000 (13:04 +0000)
src/ChangeLog
src/aggregate.c
tests/Makefile.am
tests/bugs/agg_crash.sh [new file with mode: 0755]

index a7e6320ae2ef5ff764717b8a2c5e8dca21d51de1..649add829b78e63f68afcb55f295ac4abbb3b72e 100644 (file)
@@ -1,3 +1,9 @@
+Tue Jan 25 21:01:43 WST 2005 John Darrington <john@darrington.wattle.id.au>
+
+       * aggregate.c: Initialised the complete agr_proc structure.
+       Closes bug #11675
+
+
 Sun Jan 23 23:02:21 2005  Ben Pfaff  <blp@gnu.org>
 
        * print.c: (print_trns_free) Close the dfm writer if there is one,
index ffd29166142cb2bd44512ebb80cb17d2b935f7f6..46e743c9473dd9f695dcc2d9d033930517691b24 100644 (file)
@@ -161,15 +161,8 @@ cmd_aggregate (void)
   /* Have we seen these subcommands? */
   unsigned seen = 0;
 
-  agr.writer = NULL;
-  agr.sink = NULL;
+  memset(&agr, 0 , sizeof (agr));
   agr.missing = ITEMWISE;
-  agr.sort = NULL;
-  agr.break_vars = NULL;
-  agr.agr_vars = NULL;
-  agr.dict = NULL;
-  agr.case_cnt = 0;
-  agr.prev_break = NULL;
   
   agr.dict = dict_create ();
   dict_set_label (agr.dict, dict_get_label (default_dict));
@@ -670,6 +663,7 @@ agr_destroy (struct agr_proc *agr)
     }
   if (agr->dict != NULL)
     dict_destroy (agr->dict);
+
   case_destroy (&agr->agr_case);
 }
 \f
index 66faad06b3eaaa52e98628ab997ff9d1f6bbbaae..9d051978e35f9b1354dcf0e16ad692336f749e5c 100644 (file)
@@ -41,6 +41,7 @@ TESTS = \
        command/tabs.sh \
        command/use.sh \
        command/weight.sh \
+       bugs/agg_crash.sh \
        bugs/alpha-freq.sh \
        bugs/big-input.sh \
        bugs/big-input-2.sh \
diff --git a/tests/bugs/agg_crash.sh b/tests/bugs/agg_crash.sh
new file mode 100755 (executable)
index 0000000..30d63be
--- /dev/null
@@ -0,0 +1,73 @@
+#!/bin/sh
+
+# This program tests for a bug which crashed pspp when doing a aggregate 
+# procedure
+
+TEMPDIR=/tmp/pspp-tst-$$
+TESTFILE=$TEMPDIR/`basename $0`.sps
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+     rm -rf $TEMPDIR
+}
+
+
+fail()
+{
+    echo $activity
+    echo FAILED
+    cleanup;
+    exit 1;
+}
+
+
+no_result()
+{
+    echo $activity
+    echo NO RESULT;
+    cleanup;
+    exit 2;
+}
+
+pass()
+{
+    cleanup;
+    exit 0;
+}
+
+mkdir -p $TEMPDIR
+
+cd $TEMPDIR
+
+activity="create program"
+cat > $TESTFILE <<EOF
+INPUT PROGRAM.
+LOOP c=1 TO 20.
+COMPUTE x=UNIFORM(10)
+END CASE.
+END LOOP.
+END FILE.
+END INPUT PROGRAM.
+
+AGGREGATE /BREAK=x .
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+# The above input is invalid.
+# So this will have a non zero error status.
+# But it shouldn't crash!
+activity="run_program"
+$SUPERVISOR $here/../src/pspp $TESTFILE > /dev/null
+if [ $? -ne 1 ] ; then fail ; fi
+
+
+pass;