From edf4f6b1f7e2b9c17cc86f1c63ff9b4b7e24af26 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 17 Apr 2012 20:09:34 -0700 Subject: [PATCH] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable(). Also, as long as we're checking for too-big we might as well check for too-small too. --- src/ui/gui/psppire-dict.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c index 04bd3e319c..16576dc3aa 100644 --- a/src/ui/gui/psppire-dict.c +++ b/src/ui/gui/psppire-dict.c @@ -464,17 +464,14 @@ psppire_dict_set_name (PsppireDict* d, gint idx, const gchar *name) -/* Return the IDXth variable. - Will return NULL if IDX exceeds the number of variables in the dictionary. - */ +/* Return the IDXth variable in D. */ struct variable * psppire_dict_get_variable (const PsppireDict *d, gint idx) { g_return_val_if_fail (d, NULL); g_return_val_if_fail (d->dict, NULL); - - if ( dict_get_var_cnt (d->dict) <= idx ) - return NULL; + g_return_val_if_fail (idx < 0, NULL); + g_return_val_if_fail (dict_get_var_cnt (d->dict) <= idx, NULL); return dict_get_var (d->dict, idx); } -- 2.30.2