[dw-free] Segfault in Unicode::CheckUTF8, if we pass in a non-string to LJ::is_utf8
[commit: http://hg.dwscoalition.org/dw-free/rev/522fd8d99d0c]
http://bugs.dwscoalition.org/show_bug.cgi?id=2684
Make sure text argument is treated as a string.
Patch by
exor674.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2684
Make sure text argument is treated as a string.
Patch by
Files modified:
- cgi-bin/ljtextutil.pl
--------------------------------------------------------------------------------
diff -r 1440b080e8c1 -r 522fd8d99d0c cgi-bin/ljtextutil.pl
--- a/cgi-bin/ljtextutil.pl Wed Nov 24 10:19:22 2010 -0600
+++ b/cgi-bin/ljtextutil.pl Thu Nov 25 20:24:38 2010 -0600
@@ -288,11 +288,13 @@ sub is_utf8 {
# returns: 1 if text is a valid UTF-8 stream, a reference, or null; 0 otherwise.
# </LJFUNC>
sub is_utf8_wrapper {
- my $text = shift;
+ my $text = $_[0];
- if ( defined $text && ! ref $text ) {
- return Unicode::CheckUTF8::is_utf8( $text );
+ if ( defined $text && ! ref $text && $text ) {
+ # we need to make sure $text values are treated as strings
+ return Unicode::CheckUTF8::is_utf8( '' . $text );
} else {
+ # all possible "false" values for $text are valid unicode
return 1;
}
}
--------------------------------------------------------------------------------
