bug fixed: must check the return value of vsnprintf