From c8194ee3eceac762983d7aec6e716f9f5297001b Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 21 Nov 2019 08:24:53 +0100 Subject: [PATCH] gstrfuncs: use gsize type internally for strv functions In C, the proper type for a heap allocate structure is size_t/gsize. That means, no valid (heap allocated) pointer will ever contain more bytes than size_t can represent. Hence, this integer type should also be used when operating on data like a strv array. Adjust some internal uses to use gsize instead of gint/guint. Note that g_strv_length() returns a value of type guint. So this API cannot be used on string arrays longer of arbitrary size. But that is not fixable. --- glib/gstrfuncs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c index 57aec6823..f34aca29d 100644 --- a/glib/gstrfuncs.c +++ b/glib/gstrfuncs.c @@ -1588,7 +1588,7 @@ g_ascii_strup (const gchar *str, gboolean g_str_is_ascii (const gchar *str) { - gint i; + gsize i; for (i = 0; str[i]; i++) if (str[i] & 0x80) @@ -2518,7 +2518,7 @@ g_strfreev (gchar **str_array) { if (str_array) { - int i; + gsize i; for (i = 0; str_array[i] != NULL; i++) g_free (str_array[i]); @@ -2543,7 +2543,7 @@ g_strdupv (gchar **str_array) { if (str_array) { - gint i; + gsize i; gchar **retval; i = 0; @@ -2597,7 +2597,7 @@ g_strjoinv (const gchar *separator, if (*str_array) { - gint i; + gsize i; gsize len; gsize separator_len;