On Fri, Jul 18, 2008 at 12:22:22AM +0900, TAKAHASHI Tamotsu wrote: > > Let's pretend for a moment that we have a case where every character > > in the input text needs to get converted to a string which has a > > lenght of ibl * 8 bytes. If I read it correctly, your patch will go > > into an infinite loop, with the call to iconv always returning failure > > with errno = E2BIG. > > Ugh, you are right. Thanks for the correction. > I've been off for such a long time. No problem Tamo! > Oh, I thought I was a little stingy when I took 6. Some systems > define MB_LEN_MAX == 16 or more. IMHO the performance damage with > realloc is worse than a little memory waste. (In fact, I'd rather > alloc a larger space at first than MB_LEN_MAX*ibl.) I'm inclined to agree... But we must be careful, or we will have the bloat police chasing after us. ;-) If I were going to check in such a patch, probably what I would want to do is use 16 to start (but use a #define'd macro), double it once to 32, and then give up with an error. It would be nice if iconv() worked like the snprintf() family of functions (more recently) where if the buffer used is too small, the function returns the lenght of the string it *would* write into the buffer, if it were large enough. :) -- Derek D. Martin http://www.pizzashack.org/ GPG Key ID: 0xDFBEAD02 -=-=-=-=- This message is posted from an invalid address. Replying to it will result in undeliverable mail due to spam prevention. Sorry for the inconvenience.
Attachment:
pgphHCNGzO24e.pgp
Description: PGP signature