pspp-dev
[Top][All Lists]
Advanced

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

[PATCH 11/11] psppire-dict: Better validate idx arg in psppire_dict_get_


From: Ben Pfaff
Subject: [PATCH 11/11] psppire-dict: Better validate idx arg in psppire_dict_get_variable().
Date: Sun, 15 Apr 2012 16:58:33 -0700

As long as we're checking for too-big we might as well check for
too-small too.
---
 src/ui/gui/psppire-dict.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/ui/gui/psppire-dict.c b/src/ui/gui/psppire-dict.c
index 04bd3e3..5c6cfeb 100644
--- a/src/ui/gui/psppire-dict.c
+++ b/src/ui/gui/psppire-dict.c
@@ -473,7 +473,7 @@ 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 )
+  if ( idx < 0 || dict_get_var_cnt (d->dict) <= idx )
     return NULL;
 
   return dict_get_var (d->dict, idx);
-- 
1.7.2.5




reply via email to

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