Calculate buffer size needs in float to avoid 32-bit overflow.
Nick Ing-Simmons [Tue, 2 Apr 2002 07:40:49 +0000 (07:40 +0000)]
p4raw-id: //depot/perlio@15674

ext/Encode/Encode.xs

index 05ff836..b2467d6 100644 (file)
@@ -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;