fix leak and FPE (SVN r590038)