From ca1382f24fd0a8a90dd65daf98a279d6a549d9da Mon Sep 17 00:00:00 2001 From: John Darrington Date: Wed, 4 Jul 2018 13:12:25 +0200 Subject: [PATCH] Fix crash when attempting to add a new variable in the middle of the dictionary. 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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/ui/gui/psppire-variable-sheet.c b/src/ui/gui/psppire-variable-sheet.c index 35ee7d6085..32d163f665 100644 --- a/src/ui/gui/psppire-variable-sheet.c +++ b/src/ui/gui/psppire-variable-sheet.c @@ -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); -- 2.30.2