diff --git a/.gitlab-ci/fedora-base.Dockerfile b/.gitlab-ci/fedora-base.Dockerfile index 0237b3804b..c9e428d54c 100644 --- a/.gitlab-ci/fedora-base.Dockerfile +++ b/.gitlab-ci/fedora-base.Dockerfile @@ -41,6 +41,7 @@ RUN dnf -y install \ itstool \ json-glib-devel \ lcov \ + libasan \ libattr-devel \ libepoxy-devel \ libffi-devel \ diff --git a/gsk/gsktransform.c b/gsk/gsktransform.c index 002a52a89b..aed9eae994 100644 --- a/gsk/gsktransform.c +++ b/gsk/gsktransform.c @@ -123,7 +123,8 @@ gsk_transform_alloc (const GskTransformClass *transform_class, self->transform_class = transform_class; self->category = next ? MIN (category, next->category) : category; - self->next = gsk_transform_is_identity (next) ? NULL : next; + self->next = gsk_transform_is_identity (next) ? NULL : gsk_transform_ref (next); + g_clear_pointer (&next, gsk_transform_unref); return self; } diff --git a/gtk/gtkbookmarklist.c b/gtk/gtkbookmarklist.c index 5f81147933..537389e316 100644 --- a/gtk/gtkbookmarklist.c +++ b/gtk/gtkbookmarklist.c @@ -369,6 +369,8 @@ gtk_bookmark_list_start_loading (GtkBookmarkList *self) self); g_object_unref (file); } + + g_strfreev (uris); } else { diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index ff9df272de..51b545f29d 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -768,7 +768,11 @@ parse_selector_list (GtkCssScanner *scanner, GtkCssSelector *select = _gtk_css_selector_parse (scanner->parser); if (select == NULL) - return 0; + { + for (int i = 0; i < n_selectors; i++) + g_clear_pointer (&out_selectors[i], _gtk_css_selector_free); + return 0; + } out_selectors[n_selectors] = select; n_selectors++; @@ -778,6 +782,8 @@ parse_selector_list (GtkCssScanner *scanner, gtk_css_parser_error_syntax (scanner->parser, "Only %u selectors per ruleset allowed", MAX_SELECTOR_LIST_LENGTH); + for (int i = 0; i < MAX_SELECTOR_LIST_LENGTH; i++) + g_clear_pointer (&out_selectors[i], _gtk_css_selector_free); return 0; } } @@ -806,10 +812,7 @@ parse_declaration (GtkCssScanner *scanner, name = gtk_css_parser_consume_ident (scanner->parser); if (name == NULL) - { - gtk_css_parser_end_block (scanner->parser); - return; - } + goto out; property = _gtk_style_property_lookup (name); @@ -821,25 +824,18 @@ parse_declaration (GtkCssScanner *scanner, if (!gtk_css_parser_try_token (scanner->parser, GTK_CSS_TOKEN_COLON)) { gtk_css_parser_error_syntax (scanner->parser, "Expected ':'"); - g_free (name); - gtk_css_parser_end_block (scanner->parser); - return; + goto out; } - value = _gtk_style_property_parse_value (property, - scanner->parser); + value = _gtk_style_property_parse_value (property, scanner->parser); if (value == NULL) - { - gtk_css_parser_end_block (scanner->parser); - return; - } + goto out; if (!gtk_css_parser_has_token (scanner->parser, GTK_CSS_TOKEN_EOF)) { gtk_css_parser_error_syntax (scanner->parser, "Junk at end of value for %s", property->name); - gtk_css_parser_end_block (scanner->parser); - return; + goto out; } if (gtk_keep_css_sections) @@ -884,6 +880,7 @@ parse_declaration (GtkCssScanner *scanner, gtk_css_parser_error_value (scanner->parser, "No property named \"%s\"", name); } +out: g_free (name); gtk_css_parser_end_block (scanner->parser); diff --git a/gtk/gtkdirectorylist.c b/gtk/gtkdirectorylist.c index b4a0d10014..feb3ed044c 100644 --- a/gtk/gtkdirectorylist.c +++ b/gtk/gtkdirectorylist.c @@ -570,8 +570,9 @@ got_existing_file_info_cb (GObject *source, g_file_info_set_attribute_object (info, "standard::file", G_OBJECT (file)); - iter = g_sequence_get_begin_iter (self->items); - while (!g_sequence_iter_is_end (iter)) + for (iter = g_sequence_get_begin_iter (self->items); + !g_sequence_iter_is_end (iter); + iter = g_sequence_iter_next (iter)) { GFileInfo *item = g_sequence_get (iter); GFile *f = G_FILE (g_file_info_get_attribute_object (item, "standard::file")); @@ -591,8 +592,9 @@ gtk_directory_list_remove_file (GtkDirectoryList *self, { GSequenceIter *iter; - iter = g_sequence_get_begin_iter (self->items); - while (!g_sequence_iter_is_end (iter)) + for (iter = g_sequence_get_begin_iter (self->items); + !g_sequence_iter_is_end (iter); + iter = g_sequence_iter_next (iter)) { GFileInfo *item = g_sequence_get (iter); GFile *f = G_FILE (g_file_info_get_attribute_object (item, "standard::file")); diff --git a/gtk/gtkpicture.c b/gtk/gtkpicture.c index 0833b11a6f..31d814e381 100644 --- a/gtk/gtkpicture.c +++ b/gtk/gtkpicture.c @@ -284,6 +284,7 @@ gtk_picture_dispose (GObject *object) gtk_picture_set_paintable (self, NULL); g_clear_object (&self->file); + g_clear_pointer (&self->alternative_text, g_free); G_OBJECT_CLASS (gtk_picture_parent_class)->dispose (object); }; diff --git a/gtk/gtkshortcuttrigger.c b/gtk/gtkshortcuttrigger.c index 15268ef464..65e3164b5b 100644 --- a/gtk/gtkshortcuttrigger.c +++ b/gtk/gtkshortcuttrigger.c @@ -142,11 +142,17 @@ gtk_shortcut_trigger_parse_string (const char *string) /* empty first slot */ if (*frag_a == '\0') - return NULL; + { + g_free (frag_a); + return NULL; + } /* empty second slot */ if (*frag_b == '\0') - return NULL; + { + g_free (frag_a); + return NULL; + } t1 = gtk_shortcut_trigger_parse_string (frag_a); if (t1 == NULL) diff --git a/testsuite/gdk/memorytexture.c b/testsuite/gdk/memorytexture.c index b43281e6b2..5f61b8c079 100644 --- a/testsuite/gdk/memorytexture.c +++ b/testsuite/gdk/memorytexture.c @@ -93,7 +93,7 @@ create_texture (GdkMemoryFormat format, guchar *data; int x, y; - data = g_malloc (height * stride); + data = g_malloc (height * MAX (stride, tests[format].bytes_per_pixel)); for (y = 0; y < height; y++) for (x = 0; x < width; x++) { @@ -102,7 +102,7 @@ create_texture (GdkMemoryFormat format, tests[format].bytes_per_pixel); } - bytes = g_bytes_new_static (data, height * stride); + bytes = g_bytes_new_take (data, height * MAX (stride, tests[format].bytes_per_pixel)); texture = gdk_memory_texture_new (width, height, format, bytes, diff --git a/testsuite/gtk/bitmask.c b/testsuite/gtk/bitmask.c index 75aec409a7..167e729ea7 100644 --- a/testsuite/gtk/bitmask.c +++ b/testsuite/gtk/bitmask.c @@ -316,7 +316,13 @@ test_subtract_hardcoded (void) left_str++; } - g_test_message ("%s - %s\n", _gtk_bitmask_to_string (left), _gtk_bitmask_to_string (right)); + { + char *sl = _gtk_bitmask_to_string (left); + char *sr = _gtk_bitmask_to_string (right); + g_test_message ("%s - %s\n", sl, sr); + g_free (sl); + g_free (sr); + } subtracted = _gtk_bitmask_subtract (_gtk_bitmask_copy (left), right); assert_cmpmasks (subtracted, expected); diff --git a/testsuite/gtk/filtermodel.c b/testsuite/gtk/filtermodel.c index 53c1d93b6f..5b03a93cf2 100644 --- a/testsuite/gtk/filtermodel.c +++ b/testsuite/gtk/filtermodel.c @@ -5971,6 +5971,7 @@ specific_bug_346800 (void) columns[1] = G_TYPE_BOOLEAN; store = gtk_tree_store_newv (2, columns); model = GTK_TREE_MODEL (store); + GList *junk = NULL; /*http://bugzilla.gnome.org/show_bug.cgi?id=346800 */ @@ -5981,14 +5982,14 @@ specific_bug_346800 (void) { /* allocate random amounts of junk, otherwise the filter model's arrays can expand without moving */ - g_malloc (138); + junk = g_list_append (junk, g_malloc (138)); gtk_tree_store_append (store, &node_iters[i], NULL); gtk_tree_store_set (store, &node_iters[i], 0, "something", 1, ((i%6) == 0) ? FALSE : TRUE, -1); - g_malloc (47); + junk = g_list_append (junk, g_malloc (47)); gtk_tree_store_append (store, &child_iters[i], &node_iters[i]); gtk_tree_store_set (store, &child_iters[i], 0, "something else", @@ -6007,6 +6008,8 @@ specific_bug_346800 (void) gtk_tree_model_filter_refilter (filter); } } + + g_list_free_full (junk, g_free); } static gboolean diff --git a/testsuite/gtk/shortcuts.c b/testsuite/gtk/shortcuts.c index 887d53b3b0..085e3026e2 100644 --- a/testsuite/gtk/shortcuts.c +++ b/testsuite/gtk/shortcuts.c @@ -354,6 +354,8 @@ test_trigger_trigger (void) } gdk_event_unref (event); + + g_free (keys); } gdk_surface_destroy (surface); diff --git a/testsuite/gtk/test-focus-chain.c b/testsuite/gtk/test-focus-chain.c index 5419dbc2ae..77ec3814d6 100644 --- a/testsuite/gtk/test-focus-chain.c +++ b/testsuite/gtk/test-focus-chain.c @@ -304,6 +304,7 @@ main (int argc, char **argv) g_error ("Option parsing failed: %s\n", error->message); return 1; } + g_option_context_free (context); gtk_init (); diff --git a/testsuite/gtk/textbuffer.c b/testsuite/gtk/textbuffer.c index 33b3048d3d..1f2b95ff37 100644 --- a/testsuite/gtk/textbuffer.c +++ b/testsuite/gtk/textbuffer.c @@ -1360,6 +1360,7 @@ check_buffer_contents (GtkTextBuffer *buffer, gtk_text_buffer_get_end_iter (buffer, &end); buffer_contents = gtk_text_buffer_get_text (buffer, &start, &end, FALSE); g_assert_cmpstr (buffer_contents, ==, contents); + g_free (buffer_contents); } static void diff --git a/testsuite/reftests/gtk-reftest.c b/testsuite/reftests/gtk-reftest.c index 41e28c05b9..3fd90cd3e7 100644 --- a/testsuite/reftests/gtk-reftest.c +++ b/testsuite/reftests/gtk-reftest.c @@ -78,6 +78,7 @@ parse_command_line (int *argc, char ***argv) g_print ("option parsing failed: %s\n", error->message); return FALSE; } + g_option_context_free (context); for (i = 0; i < *argc; i++) { @@ -325,6 +326,8 @@ test_ui_file (GFile *file) } remove_extra_css (provider); + + g_free (ui_file); } static int