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 |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c
index 04bd3e3..32f46f2 100644
--- a/src/ui/gui/psppire-dict.c
+++ b/src/ui/gui/psppire-dict.c
@@ -464,17 +464,13 @@ 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 || dict_get_var_cnt (d->dict) <= idx, NULL);
 
   return dict_get_var (d->dict, idx);
 }
-- 
1.7.2.5


_______________________________________________
pspp-dev mailing list
pspp-dev@gnu.org
https://lists.gnu.org/mailman/listinfo/pspp-dev

Reply via email to