Fix load_layout crash when floating node doesn't have CT_FLOATING_CON parent
Fixes #3901
This commit is contained in:
@ -170,6 +170,19 @@ static int json_end_map(void *ctx) {
|
||||
con_attach(json_node, json_node->parent, true);
|
||||
LOG("Creating window\n");
|
||||
x_con_init(json_node);
|
||||
|
||||
/* Fix erroneous JSON input regarding floating containers to avoid
|
||||
* crashing, see #3901. */
|
||||
const int old_floating_mode = json_node->floating;
|
||||
if (old_floating_mode >= FLOATING_AUTO_ON && json_node->parent->type != CT_FLOATING_CON) {
|
||||
LOG("Fixing floating node without CT_FLOATING_CON parent\n");
|
||||
|
||||
/* Force floating_enable to work */
|
||||
json_node->floating = FLOATING_AUTO_OFF;
|
||||
floating_enable(json_node, false);
|
||||
json_node->floating = old_floating_mode;
|
||||
}
|
||||
|
||||
json_node = json_node->parent;
|
||||
incomplete--;
|
||||
DLOG("incomplete = %d\n", incomplete);
|
||||
|
Reference in New Issue
Block a user