[libgda] GdaDataProxy: better check for filter expression



commit 4ce0ef41fedae7ba2967dba40202a73a5208dd73
Author: Vivien Malerba <malerba gnome-db org>
Date:   Wed May 25 23:28:24 2011 +0200

    GdaDataProxy: better check for filter expression

 libgda/gda-data-proxy.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/libgda/gda-data-proxy.c b/libgda/gda-data-proxy.c
index fcccc81..978283d 100644
--- a/libgda/gda-data-proxy.c
+++ b/libgda/gda-data-proxy.c
@@ -2917,7 +2917,8 @@ sql_where_foreach (GdaSqlAnyPart *part, GdaDataProxy *proxy, G_GNUC_UNUSED GErro
 					/* column name is "_<number>", use column: <number> - 1 */
 					gint colnum;
 					colnum = atoi (cstr+1) - 1; /* Flawfinder: ignore */
-					if (colnum >= 0) {
+					if ((colnum >= 0) &&
+					    (colnum < gda_data_model_get_n_columns ((GdaDataModel*) proxy))) {
 						GdaColumn *col = gda_data_model_describe_column ((GdaDataModel*) proxy,
 												 colnum);
 						const gchar *cname = gda_column_get_name (col);
@@ -3447,7 +3448,13 @@ gda_data_proxy_describe_column (GdaDataModel *model, gint col)
 	if (!proxy->priv->columns)
 		create_columns (proxy);
 	gda_mutex_unlock (proxy->priv->mutex);
-	return proxy->priv->columns [col];
+	if ((col < 0) || (col >= 2 * proxy->priv->model_nb_cols)) {
+		g_warning (_("Column %d out of range (0-%d)"), col,
+			   gda_data_model_get_n_columns (model) - 1);
+		return NULL;
+	}
+	else
+		return proxy->priv->columns [col];
 }
 
 static const GValue *



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