Fixed bug where gui would crash when columns were resized.
[pspp-builds.git] / src / data / category.c
index e48987a043ded9bd16012145eb69bb7840149dc9..cfde533116d9337665548163b81320e04edade0f 100644 (file)
   'cat_var'.
 */
 #include <config.h>
-#include <stdlib.h>
-#include <message.h>
-#include "alloc.h"
-#include "message.h"
+
 #include "category.h"
-#include "cat-routines.h"
+
+#include <assert.h>
+#include <stdlib.h>
 #include <string.h>
+
+#include <libpspp/alloc.h>
+#include <libpspp/message.h>
+#include "cat-routines.h"
 #include "variable.h"
 
 #define N_INITIAL_CATEGORIES 1
@@ -60,9 +63,16 @@ void
 cat_stored_values_destroy (struct variable *v)
 {
   assert (v != NULL);
+
   if (v->obs_vals != NULL)
     {
+      if (v->obs_vals->n_allocated_categories > 0)
+       {
+         free (v->obs_vals->vals);
+         v->obs_vals->vals = NULL;
+       }
       free (v->obs_vals);
+      v->obs_vals = NULL;
     }
 }