[dw-free] Segmentation Faults on Ubuntu 9.10
[commit: http://hg.dwscoalition.org/dw-free/rev/9feb8d8019d5]
http://bugs.dwscoalition.org/show_bug.cgi?id=2226
Fix one of the segfaults on Ubuntu 9.10: determining text utf8 status.
Patch by
allen.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2226
Fix one of the segfaults on Ubuntu 9.10: determining text utf8 status.
Patch by
Files modified:
- cgi-bin/ljtextutil.pl
--------------------------------------------------------------------------------
diff -r d7d294f7f0af -r 9feb8d8019d5 cgi-bin/ljtextutil.pl
--- a/cgi-bin/ljtextutil.pl Sat Feb 13 01:11:46 2010 +0000
+++ b/cgi-bin/ljtextutil.pl Sat Feb 13 01:34:55 2010 +0000
@@ -276,8 +276,25 @@ sub is_utf8 {
*stab = *{"main::LJ::"};
undef $stab{is_utf8};
}
- *LJ::is_utf8 = \&Unicode::CheckUTF8::is_utf8;
- return Unicode::CheckUTF8::is_utf8($text);
+ *LJ::is_utf8 = \&LJ::is_utf8_wrapper;
+ return LJ::is_utf8_wrapper( $text );
+}
+
+# <LJFUNC>
+# name: LJ::is_utf8_wrapper
+# des: wraps the check for UTF-8 validity.
+# args: text
+# des-text: text to check for UTF-8 validity
+# returns: 1 if text is a valid UTF-8 stream, a reference, or null; 0 otherwise.
+# </LJFUNC>
+sub is_utf8_wrapper {
+ my $text = shift;
+
+ if ( defined $text && ! ref $text ) {
+ return Unicode::CheckUTF8::is_utf8( $text );
+ } else {
+ return 1;
+ }
}
# <LJFUNC>
--------------------------------------------------------------------------------
