Avoid calling truncate with a invalid size if result_len is 0