Fixed memory leaks on as_scan_destroy.