Fixed bug 13082
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 14 May 2005 00:25:28 +0000 (00:25 +0000)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 14 May 2005 00:25:28 +0000 (00:25 +0000)
src/ChangeLog
src/dfm-read.c
tests/Makefile.am
tests/bugs/input-crash.sh [new file with mode: 0755]

index bf73f10b319e504e588d9c5c8fa98b72e8e4c74e..38401f8d68fec202bff9ba44238289cc60957cbe 100644 (file)
@@ -1,3 +1,8 @@
+Sat May 14 08:22:26 WST 2005 John Darrington <john@darrington.wattle.id.au>
+
+       * dfm-read.c: Fixed polarity of test in dfm-close-reader.  Closes 
+       Bug #13082
+
 Tue May 10 20:08:18 2005  Ben Pfaff  <blp@gnu.org>
 
        * data-in.c: (data_in) Add assertion to check input specifier.
index a293cb5f308cfc4e0afc0e9f84fbb920b9e766be..32b458e00f64be9f2b0255e38c2a9a510f6688d6 100644 (file)
@@ -78,7 +78,7 @@ dfm_close_reader (struct dfm_reader *r)
       assert (inline_open_cnt > 0);
       still_open = --inline_open_cnt;
 
-      if (!still_open) 
+      if (still_open) 
         {
           /* Skip any remaining data on the inline file. */
           while ((r->flags & DFM_EOF) == 0)
index e124e1aaf86c4b2fbe11b1579fed45f7647d3397..64c1680add0c174ec29d92c89b3223ed538bab9b 100644 (file)
@@ -65,6 +65,7 @@ TESTS = \
        bugs/get-no-file.sh \
        bugs/html-frequency.sh \
        bugs/if_crash.sh \
+       bugs/input-crash.sh \
        bugs/lag_crash.sh \
        bugs/match-files-scratch.sh \
        bugs/multipass.sh \
diff --git a/tests/bugs/input-crash.sh b/tests/bugs/input-crash.sh
new file mode 100755 (executable)
index 0000000..18461c0
--- /dev/null
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+# This program tests for a bug which caused a crash when 
+# reading invalid INPUT PROGRAM syntax.
+
+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()
+{
+     if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
+       echo "NOT cleaning $TEMPDIR"
+       return ; 
+     fi
+     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 test program"
+cat > $TESTFILE <<EOF 
+INPUT PROGRAM.
+DATA LIST /a 1-9.
+BEGIN DATA
+123456789
+END DATA.
+END INPUT PROGRAM.
+
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+# The above syntax is invalid, so this program should fail to parse
+activity="run program"
+$SUPERVISOR $here/../src/pspp --testing-mode -o raw-ascii $TESTFILE > /dev/null
+if [ $? -ne 1 ] ; then fail ; fi
+
+
+
+pass;