fixed: some issues pointed out by valgrind

cherry-picked from @notspiff I dropped the change in CWinEventsX11Imp::CWinEventsX11Imp from original commit.
IIRC Value() can be NULL (and even if there's some kind of promise that it isn't nothing is stopping it from changing that) but ValueStr() can't (as it returns a std::string).