Fix mem leak.
Work around pointer/function cast warning.