i3 - improved tiling WM


Bugfix: check symbol for NULL in binding json dump

Patch status: merged

Patch by Tony Crisci

Long description:

When dumping a binding, as is done during the binding event, check
symbol for NULL. If it is, dump json null. This prevents a crash when
running a binding that was configured with bindcode.

fixes #1379

To apply this patch, use:
curl http://cr.i3wm.org/patch/653/raw.patch | git am

b/docs/ipc

19
@@ -769,9 +769,9 @@ input_code (integer)::
20
 	If the binding was configured with +bindcode+, this will be the key code
21
 	that was given for the binding. If the binding is a mouse binding, it will be
22
 	the number of the mouse button that was pressed. Otherwise it will be 0.
23
-symbol (string)::
24
+symbol (string or null)::
25
 	If this is a keyboard binding that was configured with +bindsym+, this
26
-	field will contain the given symbol.
27
+	field will contain the given symbol. Otherwise it will be +null+.
28
 input_type (string)::
29
 	This will be +"keyboard"+ or +"mouse"+ depending on whether or not this was
30
 	a keyboard or a mouse binding.

b/src/ipc.c

35
@@ -160,7 +160,10 @@ static void dump_binding(yajl_gen gen, Binding *bind) {
36
     ystr((const char*)(bind->input_type == B_KEYBOARD ? "keyboard" : "mouse"));
37
 
38
     ystr("symbol");
39
-    ystr(bind->symbol);
40
+    if (bind->symbol == NULL)
41
+        y(null);
42
+    else
43
+        ystr(bind->symbol);
44
 
45
     ystr("command");
46
     ystr(bind->command);