Fixed crash on NULL de-referencing.
authorVitaly Buka <vitalybuka@chromium.org>
Wed, 19 Nov 2014 01:17:31 +0000 (17:17 -0800)
committerVitaly Buka <vitalybuka@chromium.org>
Wed, 19 Nov 2014 01:17:31 +0000 (17:17 -0800)
BUG=433992
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/733273002

core/src/fpdftext/fpdf_text_int.cpp

index 5b174f0..42bbffa 100644 (file)
@@ -1499,7 +1499,7 @@ void CPDF_TextPage::ProcessMarkedContent(PDFTEXT_Obj Obj)
         CPDF_ContentMarkItem& item = pMarkData->GetItem(n);
         CFX_ByteString tagStr = (CFX_ByteString)item.GetName();
         pDict = (CPDF_Dictionary*)item.GetParam();
-        CPDF_String* temp = (CPDF_String*)pDict->GetElement(FX_BSTRC("ActualText"));
+        CPDF_String* temp = (CPDF_String*)(pDict ? pDict->GetElement(FX_BSTRC("ActualText")) : NULL);
         if (temp) {
             actText = temp->GetUnicodeText();
         }
@@ -1875,30 +1875,30 @@ void CPDF_TextPage::ProcessTextObject(PDFTEXT_Obj Obj)
             }
         }
     }
-    if (bIsBidiAndMirrosInverse) {\r
-        FX_INT32 i, j;\r
-        i = iCharListStartAppend;\r
-        j = m_TempCharList.GetSize() - 1;\r
-        PAGECHAR_INFO tempCharInfo;\r
-        FX_INT32 tempIndex = 0;\r
-        for (; i < j; i++, j--) {\r
-            tempCharInfo = m_TempCharList[i];\r
-            m_TempCharList[i] = m_TempCharList[j];\r
-            m_TempCharList[j] = tempCharInfo;\r
-            tempIndex = m_TempCharList[i].m_Index;\r
-            m_TempCharList[i].m_Index = m_TempCharList[j].m_Index;\r
-            m_TempCharList[j].m_Index = tempIndex;\r
-        }\r
-        FX_WCHAR * pTempBuffer = m_TempTextBuf.GetBuffer();\r
-        i = iBufStartAppend;\r
-        j = m_TempTextBuf.GetLength() - 1;\r
-        FX_WCHAR wTemp;\r
-        for (; i < j; i++, j--) {\r
-            wTemp = pTempBuffer[i];\r
-            pTempBuffer[i] = pTempBuffer[j];\r
-            pTempBuffer[j] = wTemp;\r
-        }\r
-    }\r
+    if (bIsBidiAndMirrosInverse) {
+        FX_INT32 i, j;
+        i = iCharListStartAppend;
+        j = m_TempCharList.GetSize() - 1;
+        PAGECHAR_INFO tempCharInfo;
+        FX_INT32 tempIndex = 0;
+        for (; i < j; i++, j--) {
+            tempCharInfo = m_TempCharList[i];
+            m_TempCharList[i] = m_TempCharList[j];
+            m_TempCharList[j] = tempCharInfo;
+            tempIndex = m_TempCharList[i].m_Index;
+            m_TempCharList[i].m_Index = m_TempCharList[j].m_Index;
+            m_TempCharList[j].m_Index = tempIndex;
+        }
+        FX_WCHAR * pTempBuffer = m_TempTextBuf.GetBuffer();
+        i = iBufStartAppend;
+        j = m_TempTextBuf.GetLength() - 1;
+        FX_WCHAR wTemp;
+        for (; i < j; i++, j--) {
+            wTemp = pTempBuffer[i];
+            pTempBuffer[i] = pTempBuffer[j];
+            pTempBuffer[j] = wTemp;
+        }
+    }
 }
 FX_INT32 CPDF_TextPage::GetTextObjectWritingMode(const CPDF_TextObject* pTextObj)
 {