mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 14:31:10 +00:00
Merge branch 'wip/smcv/ubsan' into 'main'
Avoid undefined behaviour in a few simple cases See merge request GNOME/gtk!7508
This commit is contained in:
commit
1b53359cd3
@ -207,7 +207,8 @@ gdk_dmabuf_formats_new (GdkDmabufFormat *formats,
|
||||
self->n_formats = n_formats;
|
||||
self->formats = g_new (GdkDmabufFormat, n_formats);
|
||||
|
||||
memcpy (self->formats, formats, n_formats * sizeof (GdkDmabufFormat));
|
||||
if (n_formats != 0)
|
||||
memcpy (self->formats, formats, n_formats * sizeof (GdkDmabufFormat));
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -446,9 +446,9 @@ gtk_css_node_declaration_print (const GtkCssNodeDeclaration *decl,
|
||||
|
||||
for (i = 0; i < sizeof (GtkStateFlags) * 8; i++)
|
||||
{
|
||||
if (decl->state & (1 << i))
|
||||
if (decl->state & (1u << i))
|
||||
{
|
||||
const char *name = gtk_css_pseudoclass_name (1 << i);
|
||||
const char *name = gtk_css_pseudoclass_name (1u << i);
|
||||
g_assert (name);
|
||||
g_string_append_c (string, ':');
|
||||
g_string_append (string, name);
|
||||
|
@ -110,7 +110,8 @@ gtk_symbolic_paintable_snapshot_symbolic (GtkSymbolicPaintable *paintable,
|
||||
[GTK_SYMBOLIC_COLOR_SUCCESS] = { 0.3046921492332342,0.6015716792553597, 0.023437857633325704, 1.0 }
|
||||
};
|
||||
|
||||
memcpy (real_colors, colors, sizeof (GdkRGBA) * n_colors);
|
||||
if (n_colors != 0)
|
||||
memcpy (real_colors, colors, sizeof (GdkRGBA) * n_colors);
|
||||
|
||||
iface->snapshot_symbolic (paintable, snapshot, width, height, real_colors, 4);
|
||||
}
|
||||
|
@ -157,8 +157,9 @@ gtk_tim_sort_ensure_capacity (GtkTimSort *self,
|
||||
new_size |= new_size >> 4;
|
||||
new_size |= new_size >> 8;
|
||||
new_size |= new_size >> 16;
|
||||
if (sizeof(new_size) > 4)
|
||||
new_size |= new_size >> 32;
|
||||
#if GLIB_SIZEOF_SIZE_T > 4
|
||||
new_size |= new_size >> 32;
|
||||
#endif
|
||||
|
||||
new_size++;
|
||||
if (new_size == 0) /* (overflow) Not bloody likely! */
|
||||
|
Loading…
Reference in New Issue
Block a user