fixed invalid exception throw and memory leak in emit object