examples/x11.c: fix invalid removal of first list element

Fix use of memory after it was being freed.
Detected by clang scan in line 56, column 12.
examples/x11.c: fix possible memory leak if read fails

Detected by clang scan in line 224, column 21.