[poppler] glib/demo

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Sun Sep 21 07:34:39 PDT 2008


 glib/demo/forms.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

New commits:
commit 41d1edddcf84ca23c0fc39c5f4f3a49e408a9f1a
Author: Kouhei Sutou <kou at cozmixng.org>
Date:   Sun Sep 21 16:33:33 2008 +0200

    [glib-demo] Fix a crash in forms demo

diff --git a/glib/demo/forms.c b/glib/demo/forms.c
index e5eed27..e4b1fd8 100644
--- a/glib/demo/forms.c
+++ b/glib/demo/forms.c
@@ -208,11 +208,13 @@ pgd_form_field_view_set_field (GtkWidget        *field_view,
 
 		pgd_form_field_view_add_choice_items (GTK_TABLE (table), field, &selected, &row);
 
-		item = poppler_form_field_choice_get_item (field, selected);
-		text = g_strdup_printf ("%d (%s)", selected, item);
-		g_free (item);
-		pgd_table_add_property (GTK_TABLE (table), "<b>Selected item:</b>", text, &row);
-		g_free (text);
+		if (poppler_form_field_choice_get_n_items (field) > selected) {
+			item = poppler_form_field_choice_get_item (field, selected);
+			text = g_strdup_printf ("%d (%s)", selected, item);
+			g_free (item);
+			pgd_table_add_property (GTK_TABLE (table), "<b>Selected item:</b>", text, &row);
+			g_free (text);
+		}
 
 		text = poppler_form_field_choice_get_text (field);
 		pgd_table_add_property (GTK_TABLE (table), "<b>Contents:</b>", text, &row);


More information about the poppler mailing list