Hmm. The patch doesn't seem to do the right thing if buff is non-NULL and len == 0 (we simple want to return the length that would be written but *never* actually touch buff if len == 0).
The below patch should address that, but: 1. This is rushed, so I'm not sure if my assumption about apr_snprintf() not working right is valid 2. If the below will fix it. I wanted to get this out quick though... Index: strings/apr_snprintf.c =================================================================== RCS file: /home/cvs/apr/strings/apr_snprintf.c,v retrieving revision 1.27 diff -u -r1.27 apr_snprintf.c --- strings/apr_snprintf.c 25 Aug 2002 04:22:35 -0000 1.27 +++ strings/apr_snprintf.c 25 Aug 2002 18:19:18 -0000 @@ -1249,9 +1249,18 @@ va_list ap; apr_vformatter_buff_t vbuff; - /* save one byte for nul terminator */ - vbuff.curpos = buf; - vbuff.endpos = buf + len - 1; + if (len == 0) { + /* In this special case, we don't care if buff is NULL or not + * we just want to return the number of chars that would be written. + * So we leverage the fact that INS_CHAR just does the inserts + * iff the pointer is non-NULL */ + vbuff.curpos = NULL; + vbuff.endpos = NULL; + } else { + /* save one byte for nul terminator */ + vbuff.curpos = buf; + vbuff.endpos = buf + len - 1; + } va_start(ap, format); cc = apr_vformatter(snprintf_flush, &vbuff, format, ap); va_end(ap); @@ -1268,9 +1277,18 @@ int cc; apr_vformatter_buff_t vbuff; - /* save one byte for nul terminator */ - vbuff.curpos = buf; - vbuff.endpos = buf + len - 1; + if (len == 0) { + /* In this special case, we don't care if buff is NULL or not + * we just want to return the number of chars that would be written. + * So we leverage the fact that INS_CHAR just does the inserts + * iff the pointer is non-NULL */ + vbuff.curpos = NULL; + vbuff.endpos = NULL; + } else { + /* save one byte for nul terminator */ + vbuff.curpos = buf; + vbuff.endpos = buf + len - 1; + } cc = apr_vformatter(snprintf_flush, &vbuff, format, ap); if (len != 0) { *vbuff.curpos = '\0'; -- =========================================================================== Jim Jagielski [|] [EMAIL PROTECTED] [|] http://www.jaguNET.com/ "A society that will trade a little liberty for a little order will lose both and deserve neither" - T.Jefferson