If XInitThreads() is not used, dpy->lock_fns is never freed.
I'll attach a patch that works in both situations (no matter whether XInitThreads() was called or not).
Created attachment 9138 [details] [review]
Patch to fix the memleak
Tested both with XIniThreads() and without.
Fixed in 398d75528a84f4b8414eb0e363cf53b1b16f6fdf.