Chromium Code Reviews| Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp |
| diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp |
| index 752a09d83d9672e7c35541b452451910700eea6c..d97292f412c55f535bef4b23b9e961483b62ba2f 100644 |
| --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp |
| +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_objects.cpp |
| @@ -1156,25 +1156,26 @@ void CPDF_IndirectObjects::ReleaseIndirectObject(FX_DWORD objnum) { |
| pValue->Destroy(); |
| m_IndirectObjs.RemoveKey((void*)(uintptr_t)objnum); |
| } |
| -void CPDF_IndirectObjects::InsertIndirectObject(FX_DWORD objnum, |
| - CPDF_Object* pObj) { |
| - if (objnum == 0 || pObj == NULL) { |
| - return; |
| - } |
| - void* value = NULL; |
| - if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, value)) { |
| - if (value) { |
| - CPDF_Object* pValue = static_cast<CPDF_Object*>(value); |
| - if (pObj->GetGenNum() <= pValue->GetGenNum()) |
| - return; |
| - pValue->Destroy(); |
| +FX_BOOL CPDF_IndirectObjects::InsertIndirectObject(FX_DWORD objnum, |
| + CPDF_Object* pObj) { |
| + if (!objnum || !pObj) |
| + return FALSE; |
| + void* pExistingObj = nullptr; |
|
Tom Sepez
2015/12/11 00:15:07
I'd have kept value here, ...
jun_fang
2015/12/11 02:07:16
Acknowledged.
|
| + if (m_IndirectObjs.Lookup((void*)(uintptr_t)objnum, pExistingObj)) { |
| + if (pExistingObj) { |
|
Tom Sepez
2015/12/11 00:15:07
and declared pExistingObj here with the static cas
jun_fang
2015/12/11 02:07:16
Acknowledged.
|
| + if (pObj->GetGenNum() <= |
| + static_cast<CPDF_Object*>(pExistingObj)->GetGenNum()) { |
| + pObj->Destroy(); |
| + return FALSE; |
| + } |
| + static_cast<CPDF_Object*>(pExistingObj)->Destroy(); |
|
Tom Sepez
2015/12/11 00:15:07
which avoids having to write static_cast twice.
jun_fang
2015/12/11 02:07:16
Acknowledged.
|
| } |
| } |
| pObj->m_ObjNum = objnum; |
| m_IndirectObjs.SetAt((void*)(uintptr_t)objnum, pObj); |
| - if (m_LastObjNum < objnum) { |
| + if (m_LastObjNum < objnum) |
| m_LastObjNum = objnum; |
| - } |
| + return TRUE; |
| } |
| FX_DWORD CPDF_IndirectObjects::GetLastObjNum() const { |
| return m_LastObjNum; |