]> git.sur5r.net Git - i3/i3/blobdiff - src/window.c
Added assignment type 'A_NO_FOCUS' (#1416)
[i3/i3] / src / window.c
index e406752a54c63fa5bd2f2b77ddb96419cef407c3..5485bcc31fd0006b0dee655549a45a0c38867f2b 100644 (file)
@@ -26,13 +26,16 @@ void window_update_class(i3Window *win, xcb_get_property_reply_t *prop, bool bef
     /* We cannot use asprintf here since this property contains two
      * null-terminated strings (for compatibility reasons). Instead, we
      * use strdup() on both strings */
-    char *new_class = xcb_get_property_value(prop);
+    const size_t prop_length = xcb_get_property_value_length(prop);
+    char *new_class = smalloc(prop_length + 1);
+    memcpy(new_class, xcb_get_property_value(prop), prop_length);
+    new_class[prop_length] = '\0';
 
     FREE(win->class_instance);
     FREE(win->class_class);
 
     win->class_instance = sstrdup(new_class);
-    if ((strlen(new_class) + 1) < (size_t)xcb_get_property_value_length(prop))
+    if ((strlen(new_class) + 1) < prop_length)
         win->class_class = sstrdup(new_class + strlen(new_class) + 1);
     else
         win->class_class = NULL;
@@ -40,12 +43,14 @@ void window_update_class(i3Window *win, xcb_get_property_reply_t *prop, bool bef
         win->class_instance, win->class_class);
 
     if (before_mgmt) {
+        free(new_class);
         free(prop);
         return;
     }
 
     run_assignments(win);
 
+    free(new_class);
     free(prop);
 }
 
@@ -189,7 +194,7 @@ void window_update_strut_partial(i3Window *win, xcb_get_property_reply_t *prop)
     DLOG("Reserved pixels changed to: left = %d, right = %d, top = %d, bottom = %d\n",
          strut[0], strut[1], strut[2], strut[3]);
 
-    win->reserved = (struct reservedpx) {strut[0], strut[1], strut[2], strut[3]};
+    win->reserved = (struct reservedpx){strut[0], strut[1], strut[2], strut[3]};
 
     free(prop);
 }