(parse_aggregate_functions) If dict_create_var() fails, don't
authorBen Pfaff <blp@gnu.org>
Tue, 5 Apr 2005 05:29:58 +0000 (05:29 +0000)
committerBen Pfaff <blp@gnu.org>
Tue, 5 Apr 2005 05:29:58 +0000 (05:29 +0000)
dereference the resulting null pointer (PR 12427).  Also, fix double
free error.

src/ChangeLog
src/aggregate.c

index 8eb8d1260f6e29d9ab5c96a98c98f9d3859d8ead..68d0d089f0714f2d687f962c72bf22304d52ccb0 100644 (file)
@@ -1,3 +1,9 @@
+Mon Apr  4 22:27:34 2005  Ben Pfaff  <blp@gnu.org>
+
+       * aggregate.c: (parse_aggregate_functions) If dict_create_var()
+       fails, don't dereference the resulting null pointer (PR 12427).
+       Also, fix double free error.
+
 Sat Mar 19 23:06:02 2005  Ben Pfaff  <blp@gnu.org>
 
        * aggregate.c: (parse_aggregate_functions) Fix N_NO_VARS format.
index 47f34dcab440fc6fe81a573d512eb91398d8a8cf..fa89cc4934c45a8dbe28254ae123c61634921637 100644 (file)
@@ -545,16 +545,15 @@ parse_aggregate_functions (struct agr_proc *agr)
                          || function->alpha_type == NUMERIC)
                   {
                     destvar = dict_create_var (agr->dict, dest[i], 0);
-                        
-                    if ((func_index == N || func_index == NMISS)
-                        && dict_get_weight (default_dict) != NULL)
-                      destvar->print = destvar->write = f8_2; 
-                    else
-                      destvar->print = destvar->write = function->format;
+                    if (destvar != NULL) 
+                      {
+                        if ((func_index == N || func_index == NMISS)
+                            && dict_get_weight (default_dict) != NULL)
+                          destvar->print = destvar->write = f8_2; 
+                        else
+                          destvar->print = destvar->write = function->format;
+                      }
                   }
-                else 
-                  destvar = dict_create_var (agr->dict, dest[i],
-                                             v->src->width);
              } else {
                v->src = NULL;
                destvar = dict_create_var (agr->dict, dest[i], 0);
@@ -572,7 +571,6 @@ parse_aggregate_functions (struct agr_proc *agr)
                           "the aggregate variables and the break "
                           "variables."),
                     dest[i]);
-               free (dest[i]);
                goto error;
              }