another fix for flatten_args which may be heap buffer overflow