Fix memory leak if mysql_server_prepare is enabled.

Fixes MySQL bug#41815, RT#76462.
Patch provided by KNI and Masahiro Chiba.
Merge pull request #43 from mbeijen/RT76462

Fix memory leak if mysql_server_prepare is enabled.