From: Nicholas Clark Date: Sat, 15 Apr 2006 21:11:44 +0000 (+0000) Subject: Coverity notes that resource are leaked in the unfinished and never X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5860085a49b592c6a586022a93b99a5b2e2d24a5;p=p5sagit%2Fp5-mst-13.2.git Coverity notes that resource are leaked in the unfinished and never called function _utf8_to_bytes. p4raw-id: //depot/perl@27824 --- diff --git a/ext/Encode/Encode.xs b/ext/Encode/Encode.xs index b60ead4..47087da 100644 --- a/ext/Encode/Encode.xs +++ b/ext/Encode/Encode.xs @@ -696,10 +696,12 @@ CODE: /* Must do things the slow way */ U8 *dest; /* We need a copy to pass to check() */ - U8 *src = (U8*)savepv((char *)s); + U8 *src = s; U8 *send = s + len; + U8 *d0; New(83, dest, len, U8); /* I think */ + d0 = dest; while (s < send) { if (*s < 0x80){ @@ -735,6 +737,9 @@ CODE: *dest++ = (U8)uv; } } + RETVAL = dest - d0; + sv_usepvn(sv, (char *)dest, RETVAL); + SvUTF8_off(sv); } else { RETVAL = (utf8_to_bytes(s, &len) ? len : 0); }