navigation: Add some validation while sending key/mouse events
authorArun Raghavan <arun@arunraghavan.net>
Tue, 6 Jun 2017 05:38:00 +0000 (11:08 +0530)
committerArun Raghavan <arun@arunraghavan.net>
Tue, 6 Jun 2017 05:42:18 +0000 (11:12 +0530)
https://bugzilla.gnome.org/show_bug.cgi?id=783330

gst-libs/gst/video/navigation.c

index d745ae0..9e6043e 100644 (file)
@@ -122,6 +122,9 @@ void
 gst_navigation_send_key_event (GstNavigation * navigation, const char *event,
     const char *key)
 {
+  g_return_if_fail (g_strcmp0 (event, "key-press") == 0 ||
+      g_strcmp0 (event, "key-release") == 0);
+
   gst_navigation_send_event (navigation,
       gst_structure_new (GST_NAVIGATION_EVENT_NAME, "event", G_TYPE_STRING,
           event, "key", G_TYPE_STRING, key, NULL));
@@ -147,6 +150,10 @@ void
 gst_navigation_send_mouse_event (GstNavigation * navigation, const char *event,
     int button, double x, double y)
 {
+  g_return_if_fail (g_strcmp0 (event, "mouse-button-press") == 0 ||
+      g_strcmp0 (event, "mouse-button-release") == 0 ||
+      g_strcmp0 (event, "mouse-move") == 0);
+
   gst_navigation_send_event (navigation,
       gst_structure_new (GST_NAVIGATION_EVENT_NAME, "event", G_TYPE_STRING,
           event, "button", G_TYPE_INT, button, "pointer_x", G_TYPE_DOUBLE, x,