Change all g_memdup() to g_memdup2()

Using g_memdup() is dangerous due to the type of the size argument. See
https://gitlab.gnome.org/GNOME/glib/-/issues/2319 and
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1926 for details.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1708>
This commit is contained in:
Jonas Ådahl
2021-02-04 18:45:59 +01:00
parent 70c5febdd9
commit 30e1c51b33
19 changed files with 75 additions and 50 deletions

View File

@ -677,9 +677,9 @@ meta_monitor_manager_xrandr_get_crtc_gamma (MetaMonitorManager *manager,
(XID) meta_crtc_get_id (crtc));
*size = gamma->size;
*red = g_memdup (gamma->red, sizeof (unsigned short) * gamma->size);
*green = g_memdup (gamma->green, sizeof (unsigned short) * gamma->size);
*blue = g_memdup (gamma->blue, sizeof (unsigned short) * gamma->size);
*red = g_memdup2 (gamma->red, sizeof (unsigned short) * gamma->size);
*green = g_memdup2 (gamma->green, sizeof (unsigned short) * gamma->size);
*blue = g_memdup2 (gamma->blue, sizeof (unsigned short) * gamma->size);
XRRFreeGamma (gamma);
}

View File

@ -476,7 +476,7 @@ get_edid_property (Display *xdisplay,
if (actual_type == XA_INTEGER && actual_format == 8)
{
result = g_memdup (prop, nitems);
result = g_memdup2 (prop, nitems);
if (len)
*len = nitems;
}