This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[ID 20001113.003] utf8_to_uv on malformed utf returns wrong values
[perl5.git] / utf8.c
diff --git a/utf8.c b/utf8.c
index 6ddf42b..a54726f 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -312,12 +312,12 @@ malformed:
 
     if (flags & UTF8_CHECK_ONLY) {
        if (retlen)
-           *retlen = len;
+           *retlen = -1;
        return 0;
     }
 
     if (retlen)
-       *retlen = -1;
+       *retlen = expectlen ? expectlen : len;
 
     return UNICODE_REPLACEMENT_CHARACTER;
 }