pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get


From: Ben Pfaff
Subject: [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable().
Date: Mon, 16 Apr 2012 20:52:07 -0700

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]