[glib: 1/2] goption: add sanity check to input parameters
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] goption: add sanity check to input parameters
- Date: Fri, 30 Aug 2019 06:51:02 +0000 (UTC)
commit f178d1bc270d17b464e4261a94306cb93600e399
Author: Aurélien Zanelli <aurelien zanelli parrot com>
Date: Fri Aug 30 01:07:58 2019 +0200
goption: add sanity check to input parameters
To avoid dereferencing bad pointers.
Closes issue #1057
glib/goption.c | 8 ++++++++
1 file changed, 8 insertions(+)
---
diff --git a/glib/goption.c b/glib/goption.c
index 2fef7cb22..5411e8c5d 100644
--- a/glib/goption.c
+++ b/glib/goption.c
@@ -655,6 +655,7 @@ g_option_context_add_main_entries (GOptionContext *context,
const GOptionEntry *entries,
const gchar *translation_domain)
{
+ g_return_if_fail (context != NULL);
g_return_if_fail (entries != NULL);
if (!context->main_group)
@@ -841,6 +842,8 @@ g_option_context_get_help (GOptionContext *context,
GString *string;
guchar token;
+ g_return_val_if_fail (context != NULL, NULL);
+
string = g_string_sized_new (1024);
rest_description = NULL;
@@ -1958,6 +1961,8 @@ g_option_context_parse (GOptionContext *context,
gint i, j, k;
GList *list;
+ g_return_val_if_fail (context != NULL, FALSE);
+
/* Set program name */
if (!g_get_prgname())
{
@@ -2405,6 +2410,7 @@ g_option_group_add_entries (GOptionGroup *group,
{
gsize i, n_entries;
+ g_return_if_fail (group != NULL);
g_return_if_fail (entries != NULL);
for (n_entries = 0; entries[n_entries].long_name != NULL; n_entries++) ;
@@ -2745,6 +2751,8 @@ g_option_context_parse_strv (GOptionContext *context,
gboolean success;
gint argc;
+ g_return_val_if_fail (context != NULL, FALSE);
+
context->strv_mode = TRUE;
argc = arguments && *arguments ? g_strv_length (*arguments) : 0;
success = g_option_context_parse (context, &argc, arguments, error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]