Memory leaks in the test programs run by configure when using GTK 2 result in configuration failures when using -fsanitize=address in {CXX,LD}FLAGS, so fix these leaks to allow configuring using "CXXFLAGS=-fsanitize=address LDFLAGS=-fsanitize=address" together with --with-gtk=2 (this already worked correctly with the default GTK 3). Closes https://github.com/wxWidgets/wxWidgets/pull/2001