Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: fpdfsdk/src/fpdfview.cpp

Issue 845643008: Fix for crash in FPDF_GetNamedDest(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../include/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../include/fsdk_mgr.h" 8 #include "../include/fsdk_mgr.h"
9 #include "../include/fpdfview.h" 9 #include "../include/fpdfview.h"
10 #include "../include/fsdk_rendercontext.h" 10 #include "../include/fsdk_rendercontext.h"
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 if (!pDestObj) continue; 843 if (!pDestObj) continue;
844 if (i == index) break; 844 if (i == index) break;
845 i++; 845 i++;
846 } 846 }
847 } else { 847 } else {
848 pDestObj = nameTree.LookupValue(index, bsName); 848 pDestObj = nameTree.LookupValue(index, bsName);
849 } 849 }
850 if (!pDestObj) return NULL; 850 if (!pDestObj) return NULL;
851 if (pDestObj->GetType() == PDFOBJ_DICTIONARY) 851 if (pDestObj->GetType() == PDFOBJ_DICTIONARY)
852 pDestObj = ((CPDF_Dictionary*)pDestObj)->GetArray(FX_BSTRC("D")); 852 pDestObj = ((CPDF_Dictionary*)pDestObj)->GetArray(FX_BSTRC("D"));
853 if (pDestObj->GetType() != PDFOBJ_ARRAY) return NULL; 853 if (!pDestObj || pDestObj->GetType() != PDFOBJ_ARRAY) return NULL;
854 CFX_WideString wsName = PDF_DecodeText(bsName); 854 CFX_WideString wsName = PDF_DecodeText(bsName);
855 CFX_ByteString utf16Name = wsName.UTF16LE_Encode(); 855 CFX_ByteString utf16Name = wsName.UTF16LE_Encode();
856 unsigned int len = utf16Name.GetLength(); 856 unsigned int len = utf16Name.GetLength();
857 if (!buffer) { 857 if (!buffer) {
858 buflen = len + 2; 858 buflen = len + 2;
859 } else if (buflen >= len + 2) { 859 } else if (buflen >= len + 2) {
860 memcpy(buffer, utf16Name.c_str(), len); 860 memcpy(buffer, utf16Name.c_str(), len);
861 ((FX_BYTE*)buffer)[len] = 0; 861 ((FX_BYTE*)buffer)[len] = 0;
862 ((FX_BYTE*)buffer)[len + 1] = 0; 862 ((FX_BYTE*)buffer)[len + 1] = 0;
863 } else { 863 } else {
864 len = -1; 864 len = -1;
Tom Sepez 2015/01/20 18:42:28 nit: Bo, this looks wrong. Did you want to set bu
Bo Xu 2015/01/20 18:45:56 Yep, should be buflen = -1;
865 } 865 }
866 return (FPDF_DEST)pDestObj; 866 return (FPDF_DEST)pDestObj;
867 } 867 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698