factor out strbuf_expand_bad_format()