[Top][All Lists]
[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
- [PATCH 00/13] second batch of psppsheet changes, Ben Pfaff, 2012/04/16
- [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable().,
Ben Pfaff <=
- Re: [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable()., John Darrington, 2012/04/17
- Re: [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable()., Ben Pfaff, 2012/04/18
- Re: [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable()., John Darrington, 2012/04/18
- Re: [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable()., Ben Pfaff, 2012/04/19
- Re: [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable()., Ben Pfaff, 2012/04/21
- Re: [PATCH 01/13] psppire-dict: g_return_if_fail for idx in psppire_dict_get_variable()., John Darrington, 2012/04/21
[PATCH 02/13] gui: Use canonical names for signals., Ben Pfaff, 2012/04/16
[PATCH 03/13] gui: Add undocumented --measure-startup option., Ben Pfaff, 2012/04/16