From 9af2838a91fdbb84549622652d25ec557278c6c5 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Tue, 5 Oct 2004 20:04:18 +0000 Subject: [PATCH] Add check for if argc is 0. 2004-10-05 Anders Carlsson * glib/goption.c: (g_option_context_parse): Add check for if argc is 0. * tests/option-test.c: (empty_test3), (main): Add test case. --- ChangeLog | 8 ++++++++ ChangeLog.pre-2-10 | 8 ++++++++ ChangeLog.pre-2-12 | 8 ++++++++ ChangeLog.pre-2-6 | 8 ++++++++ ChangeLog.pre-2-8 | 8 ++++++++ glib/goption.c | 2 +- tests/option-test.c | 19 ++++++++++++++++++- 7 files changed, 59 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 60bcde134..19801fa7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-10-05 Anders Carlsson + + * glib/goption.c: (g_option_context_parse): + Add check for if argc is 0. + + * tests/option-test.c: (empty_test3), (main): + Add test case. + 2004-10-05 Matthias Clasen * NEWS: Update diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 60bcde134..19801fa7e 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,11 @@ +2004-10-05 Anders Carlsson + + * glib/goption.c: (g_option_context_parse): + Add check for if argc is 0. + + * tests/option-test.c: (empty_test3), (main): + Add test case. + 2004-10-05 Matthias Clasen * NEWS: Update diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 60bcde134..19801fa7e 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,11 @@ +2004-10-05 Anders Carlsson + + * glib/goption.c: (g_option_context_parse): + Add check for if argc is 0. + + * tests/option-test.c: (empty_test3), (main): + Add test case. + 2004-10-05 Matthias Clasen * NEWS: Update diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 60bcde134..19801fa7e 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,11 @@ +2004-10-05 Anders Carlsson + + * glib/goption.c: (g_option_context_parse): + Add check for if argc is 0. + + * tests/option-test.c: (empty_test3), (main): + Add test case. + 2004-10-05 Matthias Clasen * NEWS: Update diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 60bcde134..19801fa7e 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,11 @@ +2004-10-05 Anders Carlsson + + * glib/goption.c: (g_option_context_parse): + Add check for if argc is 0. + + * tests/option-test.c: (empty_test3), (main): + Add test case. + 2004-10-05 Matthias Clasen * NEWS: Update diff --git a/glib/goption.c b/glib/goption.c index 186850581..8001bad37 100644 --- a/glib/goption.c +++ b/glib/goption.c @@ -825,7 +825,7 @@ g_option_context_parse (GOptionContext *context, GList *list; /* Set program name */ - if (argc && argv) + if (argc && argv && *argc) { gchar *prgname; diff --git a/tests/option-test.c b/tests/option-test.c index d08b2238a..daf75916a 100644 --- a/tests/option-test.c +++ b/tests/option-test.c @@ -508,6 +508,22 @@ empty_test2 (void) g_option_context_free (context); } +void +empty_test3 (void) +{ + GOptionContext *context; + gint argc; + gchar **argv; + + argc = 0; + argv = NULL; + + context = g_option_context_new (NULL); + g_option_context_parse (context, &argc, &argv, NULL); + + g_option_context_free (context); +} + int main (int argc, char **argv) { @@ -537,6 +553,7 @@ main (int argc, char **argv) /* Test parsing empty args */ empty_test1 (); empty_test2 (); - + empty_test3 (); + return 0; }