Possible use of NULL value in gdkscreen-x11 for randr13 in gtk-3-24
Hello,
my PR #6680 introduced code that uses a null pointer instead of the monitor name to set the monitor's model. Impact is low (randr13 is quite old and unlikely to be used, monitor model has not real relevance since it's always the same as the name).
The issue is there:
https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/x11/gdkscreen-x11.c#L845-888
L845 - name is copied
L854 - copy is passed to the monitor object via g_steal_pointer
. name is NULL now
L885 - name (which is NULL) is used to set the model
L887 - name (which is NULL) is freed. This has no effect.
Suggested solution 1:
- no
g_strndup
in L845 -
g_strndup
instead ofg_steal_pointer
in L854 - remove L887
Suggested solution 2:
-
g_strndup
instead ofg_steal_pointer
in L854 - all other unchanged
- Advantage: Code is better readable (clear who is the owner of "name", create and freed in the method)
- Disadvantage: Name is copied 1 more time