fix memory leak
use NF_NEW to manage memory; merge