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

Side by Side Diff: fpdfsdk/include/fsdk_mgr.h

Issue 354673002: Fix and integer overflow issue in SDK's QuickSort (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 5 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 #ifndef _FPDFSDK_MGR_H 7 #ifndef _FPDFSDK_MGR_H
8 #define _FPDFSDK_MGR_H 8 #define _FPDFSDK_MGR_H
9 9
10 #include "fsdk_common.h" 10 #include "fsdk_common.h"
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 557
558 int iGreate = (*pCompare)(Value1, Value2); 558 int iGreate = (*pCompare)(Value1, Value2);
559 if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0 )) 559 if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0 ))
560 { 560 {
561 this->SetAt(nStartPos, Value2); 561 this->SetAt(nStartPos, Value2);
562 this->SetAt(nStopPos, Value1); 562 this->SetAt(nStopPos, Value1);
563 } 563 }
564 return; 564 return;
565 } 565 }
566 566
567 » » FX_UINT m = (nStartPos + nStopPos) / 2; 567 » » FX_UINT m = nStartPos + (nStopPos - nStartPos) / 2;
568 FX_UINT i = nStartPos; 568 FX_UINT i = nStartPos;
569 569
570 TYPE Value = this->GetAt(m); 570 TYPE Value = this->GetAt(m);
571 571
572 while (i < m) 572 while (i < m)
573 { 573 {
574 TYPE temp = this->GetAt(i); 574 TYPE temp = this->GetAt(i);
575 575
576 int iGreate = (*pCompare)(temp, Value); 576 int iGreate = (*pCompare)(temp, Value);
577 if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0 )) 577 if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0 ))
(...skipping 28 matching lines...) Expand all
606 } 606 }
607 607
608 if (nStartPos < m) QuickSort(nStartPos, m, bAscend, pCompare); 608 if (nStartPos < m) QuickSort(nStartPos, m, bAscend, pCompare);
609 if (nStopPos > m) QuickSort(m, nStopPos, bAscend, pCompare); 609 if (nStopPos > m) QuickSort(m, nStopPos, bAscend, pCompare);
610 } 610 }
611 }; 611 };
612 612
613 613
614 #endif //_FPDFSDK_MGR_H 614 #endif //_FPDFSDK_MGR_H
615 615
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