From: Ben Pfaff Date: Wed, 18 Apr 2012 03:09:34 +0000 (-0700) Subject: psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=edf4f6b1f7e2b9c17cc86f1c63ff9b4b7e24af26 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. --- 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); }