GNOME Bugzilla – Bug 660955
gst_type_register_static_full: guard against large instance sizes that don't fit into a guint16
Last modified: 2011-10-10 18:44:54 UTC
Suppose I made a mistake (I actually did!) and had my element instance size exceed 16 bit. I used GST_BOILERPLATE_FULL() to declare it. GST_BOILERPLATE_FULL() calls gst_type_register_static_full() to register new type with glib. For some reason that I don't understand gst_type_register_static_full() declares instance_size parameter as guint and then internally casts it into guint16 probably suppressing corresponding warning(s). Why? If it were to declare instance_size as guint16, the compiler would (hopefully) throw a warning if sizeof(type) exceeded 16 bit. That would caught an unsuspecting dev right there on the spot. I filed a bug against glib to see if they could add an assert or something if the type size exceeds 16 bit. See https://bugzilla.gnome.org/show_bug.cgi?id=659916. However in this case they obviously can't do anything as the cast to guint16 has been done already by gst_type_register_static_full(). I suggest changing instance_size parameter of gst_type_register_static_full() to guint16. If that is not possible for compatibility or some other reason, consider adding an assert to gst_type_register_static_full() to ensure that passed instance_size is within the range. Regards, -- Max Paklin.
Can't change the function signature in the ABI stable series unfortunately, but we can of course add some guards: In 0.10 stable branch: commit 56e27b0546a358c237737cace96c59623a0a858e Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Mon Oct 10 19:41:33 2011 +0100 utils: catch invalid instance sizes in gst_type_register_static_full() Add guards to catch overly large instance sizes. https://bugzilla.gnome.org/show_bug.cgi?id=660955 In 0.11 branch: commit 01c11ebf082aeec5b8f68ece1530c451f23b1822 Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Mon Oct 10 19:30:34 2011 +0100 utils: remove gst_type_register_static_full() It was only really used by GST_BOILERPLATE, and that is no more. https://bugzilla.gnome.org/show_bug.cgi?id=660955