From: Nick Ing-Simmons Date: Tue, 2 Apr 2002 07:40:49 +0000 (+0000) Subject: Calculate buffer size needs in float to avoid 32-bit overflow. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c98ca92ffec2ea20f1b8832ed8ba117f887c6688;p=p5sagit%2Fp5-mst-13.2.git Calculate buffer size needs in float to avoid 32-bit overflow. p4raw-id: //depot/perlio@15674 --- diff --git a/ext/Encode/Encode.xs b/ext/Encode/Encode.xs index 05ff836..b2467d6 100644 --- a/ext/Encode/Encode.xs +++ b/ext/Encode/Encode.xs @@ -517,7 +517,11 @@ encode_method(pTHX_ encode_t * enc, encpage_t * dir, SV * src, sdone += slen; ddone += dlen; if (sdone) { - need = (tlen*SvLEN(dst)+sdone-1)/sdone+UTF8_MAXLEN; + need = (1.0*tlen*SvLEN(dst)+sdone-1)/sdone+UTF8_MAXLEN; +#if 0 + Perl_warn(aTHX_ "Done %d/%d had %d need %d", + sdone, tlen, SvLEN(dst), need); +#endif } else { need = SvLEN(dst) + UTF8_MAXLEN;