]> git.sur5r.net Git - i3/i3/blobdiff - src/window.c
Merge branch 'release-4.16.1'
[i3/i3] / src / window.c
index db6215d0cffcd93f15b696d264d39d5419ee3568..6128255686942f80b74f491a22fb296ef1d47da6 100644 (file)
@@ -74,8 +74,12 @@ void window_update_name(i3Window *win, xcb_get_property_reply_t *prop, bool befo
     }
 
     i3string_free(win->name);
-    win->name = i3string_from_utf8_with_length(xcb_get_property_value(prop),
-                                               xcb_get_property_value_length(prop));
+
+    /* Truncate the name at the first zero byte. See #3515. */
+    const int len = xcb_get_property_value_length(prop);
+    char *name = sstrndup(xcb_get_property_value(prop), len);
+    win->name = i3string_from_utf8(name);
+    free(name);
 
     Con *con = con_by_window_id(win->id);
     if (con != NULL && con->title_format != NULL) {
@@ -119,8 +123,10 @@ void window_update_name_legacy(i3Window *win, xcb_get_property_reply_t *prop, bo
     }
 
     i3string_free(win->name);
-    win->name = i3string_from_utf8_with_length(xcb_get_property_value(prop),
-                                               xcb_get_property_value_length(prop));
+    const int len = xcb_get_property_value_length(prop);
+    char *name = sstrndup(xcb_get_property_value(prop), len);
+    win->name = i3string_from_utf8(name);
+    free(name);
 
     Con *con = con_by_window_id(win->id);
     if (con != NULL && con->title_format != NULL) {
@@ -316,7 +322,7 @@ void window_update_motif_hints(i3Window *win, xcb_get_property_reply_t *prop, bo
      * documentation of this hint is nowhere to be found.
      * For more information see:
      * https://people.gnome.org/~tthurman/docs/metacity/xprops_8h-source.html
-     * http://stackoverflow.com/questions/13787553/detect-if-a-x11-window-has-decorations
+     * https://stackoverflow.com/questions/13787553/detect-if-a-x11-window-has-decorations
      */
 #define MWM_HINTS_FLAGS_FIELD 0
 #define MWM_HINTS_DECORATIONS_FIELD 2