Using g_memdup() is dangerous due to the type of the size argument. See glib!1926 (merged) for details.