fix bug of mem leak, free the left msgs if send error