Commit 84ab33fd3e3ac55f4fb2a379ce5b1c309a2c5cdc

henry 2003-02-27T22:28:18

Fixed null string bug in BBox

diff --git a/src/FTFont.cpp b/src/FTFont.cpp
index 0e3f5c3..438105a 100755
--- a/src/FTFont.cpp
+++ b/src/FTFont.cpp
@@ -105,7 +105,8 @@ void FTFont::BBox( const char* string,
                    float& llx, float& lly, float& llz, float& urx, float& ury, float& urz)
 {
     FTBBox totalBBox;
-    if( NULL != *string)
+
+    if((NULL != string) && ('\0' != *string))
     {
         const unsigned char* c = (unsigned char*)string;
 
@@ -140,7 +141,7 @@ void FTFont::BBox( const wchar_t* string,
 {
     FTBBox totalBBox;
 
-    if( NULL != *string)
+    if((NULL != string) && ('\0' != *string))
     {
         const wchar_t* c = string;
 
diff --git a/test/FTFont-Test.cpp b/test/FTFont-Test.cpp
index e3272d9..7d98107 100755
--- a/test/FTFont-Test.cpp
+++ b/test/FTFont-Test.cpp
@@ -166,9 +166,18 @@ class FTFontTest : public CppUnit::TestCase
             CPPUNIT_ASSERT_DOUBLES_EQUAL( 134.28, urx, 0.01);
             CPPUNIT_ASSERT_DOUBLES_EQUAL(  61.12, ury, 0.01);
             CPPUNIT_ASSERT_DOUBLES_EQUAL(   0.00, urz, 0.01);
-            
+
             testFont->BBox( BAD_UNICODE_TEST_STRING, llx, lly, llz, urx, ury, urz);
-        
+
+            CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, llx, 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, lly, 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, llz, 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, urx, 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, ury, 0.01);
+            CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, urz, 0.01);
+            
+            testFont->BBox( (char*)0, llx, lly, llz, urx, ury, urz);
+
             CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, llx, 0.01);
             CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, lly, 0.01);
             CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, llz, 0.01);