Fix memory leaks in MySQL library