From 481c242ba127069bed993fc7cc79a0889830ab6b Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 20 Mar 2012 09:49:49 +0100 Subject: [PATCH] goptions: ensure that FIO_OPT_STR_VAL doesn't exceed max multiplier Signed-off-by: Jens Axboe --- goptions.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/goptions.c b/goptions.c index 30edd5cd..f1148bf4 100644 --- a/goptions.c +++ b/goptions.c @@ -43,6 +43,7 @@ struct gopt_str_val { struct gopt gopt; GtkWidget *spin; GtkWidget *combo; + unsigned int maxindex; }; #define GOPT_RANGE_SPIN 4 @@ -601,9 +602,12 @@ static void gopt_str_val_spin_wrapped(GtkSpinButton *spin, gpointer data) * Can't rely on exact value, as fast changes increment >= 1 */ if (!val) { - val = 1; index = gtk_combo_box_get_active(GTK_COMBO_BOX(g->combo)); - gtk_combo_box_set_active(GTK_COMBO_BOX(g->combo), ++index); + if (index + 1 <= g->maxindex) { + val = 1; + gtk_combo_box_set_active(GTK_COMBO_BOX(g->combo), ++index); + } else + val = 1023; gtk_spin_button_set_value(spin, val); } else { index = gtk_combo_box_get_active(GTK_COMBO_BOX(g->combo)); @@ -644,6 +648,7 @@ static struct gopt *gopt_new_str_val(struct fio_option *o, gtk_combo_box_append_text(GTK_COMBO_BOX(g->combo), postfix[i]); i++; } + g->maxindex = i - 1; gtk_combo_box_set_active(GTK_COMBO_BOX(g->combo), 0); gtk_box_pack_start(GTK_BOX(g->gopt.box), g->combo, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(g->gopt.box), label, FALSE, FALSE, 3); -- 2.25.1