Fix bug in autorecode - strings vs. /group
authorJohn Darrington <john@darrington.wattle.id.au>
Mon, 4 Oct 2010 19:47:44 +0000 (21:47 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Mon, 4 Oct 2010 19:51:16 +0000 (21:51 +0200)
Fixed a bug which caused autorecode to crash when the /GROUP
subcommand was used concurrently with variables of different widths.

src/language/stats/autorecode.c
tests/language/stats/autorecode.at

index ce818cff1169f7e2fd61a15d926942fe405474ca..2a72aaea82ecd266a1e6a81bbd5857fdecd52e54 100644 (file)
@@ -294,13 +294,12 @@ arc_free (struct autorecode_pgm *arc)
       for (i = 0; i < arc->n_specs; i++)
         {
           struct arc_spec *spec = &arc->specs[i];
-          int width = var_get_width (spec->src);
           struct arc_item *item, *next;
 
          HMAP_FOR_EACH_SAFE (item, next, struct arc_item, hmap_node,
                              spec->items)
            {
-             value_destroy (&item->from, width);
+             value_destroy (&item->from, item->width);
              hmap_delete (spec->items, &item->hmap_node);
              free (item);
            }
index 3b27aa833d8448e8dbc5628ec5a20c98ffb40194..bd9d59f7c45dfaa2259e7abe15c2e0684b0728c5 100644 (file)
@@ -176,3 +176,33 @@ a,b
 
 AT_CLEANUP
 
+
+dnl Tests for a crash which happened when the /GROUP subcommand
+dnl appeared with string variables of different widths.
+AT_SETUP([AUTORECODE group vs. strings])
+AT_DATA([ar-strings.sps],
+  [data list notable list /a (a12) b (a6).
+begin data.
+one    nine
+two    ten
+three  eleven 
+four   nought
+end data.
+
+autorecode a b into x y 
+       /group.
+
+list.
+])
+
+AT_CHECK([pspp -O format=csv ar-strings.sps], [0],
+[dnl
+Table: Data List
+a,b,x,y
+one         ,nine  ,5.00,3.00
+two         ,ten   ,8.00,6.00
+three       ,eleven,7.00,1.00
+four        ,nought,2.00,4.00
+])
+
+AT_CLEANUP