]> git.lizzy.rs Git - bspwm.git/commitdiff
Prevent potential memory leak
authorBastien Dejean <nihilhill@gmail.com>
Tue, 17 Nov 2015 10:13:25 +0000 (11:13 +0100)
committerBastien Dejean <nihilhill@gmail.com>
Tue, 17 Nov 2015 10:13:25 +0000 (11:13 +0100)
query.c

diff --git a/query.c b/query.c
index 6592dc9ed6f65e77859477bdfd11202c226e4990..18cfa74d2cfbaa95b85ed68f2e06226aa9a64f63 100644 (file)
--- a/query.c
+++ b/query.c
@@ -232,13 +232,19 @@ bool node_from_desc(char *desc, coordinates_t *ref, coordinates_t *dst)
                } else if (streq("!focused", tok)) {
                        sel.focused = OPTION_FALSE;
                } else if (streq("below", tok)) {
-                       sel.layer = malloc(sizeof(stack_layer_t));
+                       if (sel.layer == NULL) {
+                               sel.layer = malloc(sizeof(stack_layer_t));
+                       }
                        *(sel.layer) = LAYER_BELOW;
                } else if (streq("normal", tok)) {
-                       sel.layer = malloc(sizeof(stack_layer_t));
+                       if (sel.layer == NULL) {
+                               sel.layer = malloc(sizeof(stack_layer_t));
+                       }
                        *(sel.layer) = LAYER_NORMAL;
                } else if (streq("above", tok)) {
-                       sel.layer = malloc(sizeof(stack_layer_t));
+                       if (sel.layer == NULL) {
+                               sel.layer = malloc(sizeof(stack_layer_t));
+                       }
                        *(sel.layer) = LAYER_ABOVE;
                }
        }