From b66e4cd64c939d5a1fb83dd1ebb6adabbf95ac01 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Fri, 12 Apr 2019 22:38:44 +0200 Subject: [PATCH] gtkcomposetable: use g_size_checked_mul() for overflow checking The check was added in !741, this replaces it with g_size_checked_mul() --- gtk/gtkcomposetable.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gtk/gtkcomposetable.c b/gtk/gtkcomposetable.c index e451cdb3bf..c355c6a7bd 100644 --- a/gtk/gtkcomposetable.c +++ b/gtk/gtkcomposetable.c @@ -837,7 +837,6 @@ gtk_compose_table_list_add_array (GSList *compose_tables, GtkComposeTable *compose_table; gsize n_index_stride; gsize length; - gsize max_size = (gsize) -1; int i; guint16 *gtk_compose_seqs = NULL; @@ -845,13 +844,12 @@ gtk_compose_table_list_add_array (GSList *compose_tables, g_return_val_if_fail (max_seq_len <= GTK_MAX_COMPOSE_LEN, compose_tables); n_index_stride = MIN (max_seq_len, GTK_MAX_COMPOSE_LEN) + 2; - if (n_seqs > max_size / n_index_stride) + if (!g_size_checked_mul (&length, n_index_stride, n_seqs)) { g_critical ("Overflow in the compose sequences"); return compose_tables; } - length = n_index_stride * n_seqs; hash = gtk_compose_table_data_hash (data, length); if (g_slist_find_custom (compose_tables, GINT_TO_POINTER (hash), gtk_compose_table_find) != NULL)