From: John Darrington Date: Mon, 4 Oct 2010 19:47:44 +0000 (+0200) Subject: Fix bug in autorecode - strings vs. /group X-Git-Tag: v0.7.6~99 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp-builds.git;a=commitdiff_plain;h=60a5a715819916ddc5df53451221436995a71356 Fix bug in autorecode - strings vs. /group Fixed a bug which caused autorecode to crash when the /GROUP subcommand was used concurrently with variables of different widths. --- diff --git a/src/language/stats/autorecode.c b/src/language/stats/autorecode.c index ce818cff..2a72aaea 100644 --- a/src/language/stats/autorecode.c +++ b/src/language/stats/autorecode.c @@ -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); } diff --git a/tests/language/stats/autorecode.at b/tests/language/stats/autorecode.at index 3b27aa83..bd9d59f7 100644 --- a/tests/language/stats/autorecode.at +++ b/tests/language/stats/autorecode.at @@ -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