[mutter] [MutterWindow] Fixed potential NULL dereference



commit e811109566a950d3db5d955ac0a2e304874bae91
Author: Tomas Frydrych <tf linux intel com>
Date:   Fri Oct 9 16:50:38 2009 +0100

    [MutterWindow] Fixed potential NULL dereference
    
    Avoid dereferencing NULL when the window is not yet placed on a workspace.
    Added doc comment, noting this function is deprecated.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=592567

 src/compositor/mutter-window.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/compositor/mutter-window.c b/src/compositor/mutter-window.c
index 83080f8..18b815d 100644
--- a/src/compositor/mutter-window.c
+++ b/src/compositor/mutter-window.c
@@ -722,6 +722,18 @@ const char *mutter_window_get_description (MutterWindow *self)
   return self->priv->desc;
 }
 
+/**
+ * mutter_window_get_workspace:
+ * @self: #MutterWindow
+ *
+ * Returns the index of workspace on which this window is located; if the
+ * window is sticky, or is not currently located on any workspace, returns -1.
+ * This function is deprecated  and should not be used in newly written code;
+ * meta_window_get_workspace() instead.
+ *
+ * Return value: (transfer none): index of workspace on which this window is
+ * located.
+ */
 gint
 mutter_window_get_workspace (MutterWindow *self)
 {
@@ -738,6 +750,9 @@ mutter_window_get_workspace (MutterWindow *self)
 
   workspace = meta_window_get_workspace (priv->window);
 
+  if (!workspace)
+    return -1;
+
   return meta_workspace_index (workspace);
 }
 



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