[spice-gtk v1] gstaudio: fix ci due potential null pointer dereference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Victor Toso <me@xxxxxxxxxxxxxx>

Can't happen as GstElement *e is not NULL but doing extra G_OBJECT(e) cast
guarantees this for compiler.

 > spice-gstaudio.c: In function ‘playback_volume_changed’:
 > /usr/include/glib-2.0/gobject/gtype.h:2280:70: error: potential null pointer dereference [-Werror=null-dereference]
 >  #define _G_TYPE_IGC(ip, gt, ct)         ((ct*) (((GTypeInstance*) ip)->g_class))
 >                                                 ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
 > /usr/include/glib-2.0/gobject/gtype.h:525:66: note: in expansion of macro ‘_G_TYPE_IGC’
 >  #define G_TYPE_INSTANCE_GET_CLASS(instance, g_type, c_type)     (_G_TYPE_IGC ((instance), (g_type), c_type))
 >                                                                   ^~~~~~~~~~~
 > /usr/include/glib-2.0/gobject/gobject.h:86:38: note: in expansion of macro ‘G_TYPE_INSTANCE_GET_CLASS’
 >  #define G_OBJECT_GET_CLASS(object)  (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass))
 >                                       ^~~~~~~~~~~~~~~~~~~~~~~~~
 > spice-gstaudio.c:373:45: note: in expansion of macro ‘G_OBJECT_GET_CLASS’
 >      } else if (g_object_class_find_property(G_OBJECT_GET_CLASS (e), "volume") != NULL) {
                                                 ^~~~~~~~~~~~~~~~~~

Signed-off-by: Victor Toso <victortoso@xxxxxxxxxx>
---

 Working CI: https://gitlab.freedesktop.org/victortoso/spice-gtk/pipelines/15885

 src/spice-gstaudio.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/spice-gstaudio.c b/src/spice-gstaudio.c
index 51ff028..b2d9cd3 100644
--- a/src/spice-gstaudio.c
+++ b/src/spice-gstaudio.c
@@ -370,7 +370,7 @@ static void playback_volume_changed(GObject *object, GParamSpec *pspec, gpointer
 
     if (GST_IS_STREAM_VOLUME(e)) {
         gst_stream_volume_set_volume(GST_STREAM_VOLUME(e), GST_STREAM_VOLUME_FORMAT_CUBIC, vol);
-    } else if (g_object_class_find_property(G_OBJECT_GET_CLASS (e), "volume") != NULL) {
+    } else if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(e)), "volume") != NULL) {
         g_object_set(e, "volume", vol, NULL);
     } else {
         g_warning("playback: ignoring volume change on %s", gst_element_get_name(e));
@@ -399,7 +399,7 @@ static void playback_mute_changed(GObject *object, GParamSpec *pspec, gpointer d
 
     if (GST_IS_STREAM_VOLUME(e)) {
         gst_stream_volume_set_mute(GST_STREAM_VOLUME(e), mute);
-    } else if (g_object_class_find_property(G_OBJECT_GET_CLASS (e), "mute") != NULL) {
+    } else if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(e)), "mute") != NULL) {
         g_object_set(e, "mute", mute, NULL);
     } else {
         g_warning("playback: ignoring mute change on %s", gst_element_get_name(e));
@@ -437,7 +437,7 @@ static void record_volume_changed(GObject *object, GParamSpec *pspec, gpointer d
 
     if (GST_IS_STREAM_VOLUME(e)) {
         gst_stream_volume_set_volume(GST_STREAM_VOLUME(e), GST_STREAM_VOLUME_FORMAT_CUBIC, vol);
-    } else if (g_object_class_find_property(G_OBJECT_GET_CLASS (e), "volume") != NULL) {
+    } else if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(e)), "volume") != NULL) {
         g_object_set(e, "volume", vol, NULL);
     } else {
         g_warning("record: ignoring volume change on %s", gst_element_get_name(e));
@@ -466,7 +466,7 @@ static void record_mute_changed(GObject *object, GParamSpec *pspec, gpointer dat
 
     if (GST_IS_STREAM_VOLUME (e)) {
         gst_stream_volume_set_mute(GST_STREAM_VOLUME(e), mute);
-    } else if (g_object_class_find_property(G_OBJECT_GET_CLASS (e), "mute") != NULL) {
+    } else if (g_object_class_find_property(G_OBJECT_GET_CLASS(G_OBJECT(e)), "mute") != NULL) {
         g_object_set(e, "mute", mute, NULL);
     } else {
         g_warning("record: ignoring mute change on %s", gst_element_get_name(e));
-- 
2.20.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]