Fix negative/huge mallocs in PE parser and fix invalid fd close