Fix crash when attempting to add a new variable in the middle of the dictionary.
authorJohn Darrington <john@darrington.wattle.id.au>
Wed, 4 Jul 2018 11:12:25 +0000 (13:12 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 4 Jul 2018 11:15:53 +0000 (13:15 +0200)
Fixes bug #52551.

* src/ui/gui/psppire-variable-sheet.c (change_var_property): Don't attempt to
  alter a variable property if it's index is more than one below the last index.

src/ui/gui/psppire-variable-sheet.c

index 35ee7d6085d636083ae072f99be88ce8654bb799..32d163f66578a579f16e33a6f9be5ba4fb091041 100644 (file)
@@ -305,6 +305,10 @@ change_var_property (PsppireVariableSheet *var_sheet, gint col, gint row, const
   PsppireDict *dict = NULL;
   g_object_get (var_sheet, "data-model", &dict, NULL);
 
+  int n_rows = psppire_dict_get_var_cnt (dict);
+  if (row > n_rows)
+    return;
+
   /* Return the IDXth variable */
   struct variable *var =  psppire_dict_get_variable (dict, row);