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

Unified Diff: third_party/bigint/BigUnsigned.cc

Issue 754743003: Modify big integer library (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Add copyright notice Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/bigint/BigUnsigned.cc
diff --git a/third_party/bigint/BigUnsigned.cc b/third_party/bigint/BigUnsigned.cc
index d7f9889cc69846de1030d740748789a506802bab..2acb9975125f0d55767a91b81fc56b36c03d8a5e 100644
--- a/third_party/bigint/BigUnsigned.cc
+++ b/third_party/bigint/BigUnsigned.cc
@@ -1,3 +1,9 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code by Matt McCutchen, see the LICENSE file
+
#include "BigUnsigned.hh"
// Memory management definitions have moved to the bottom of NumberlikeArray.hh.
@@ -189,8 +195,12 @@ void BigUnsigned::subtract(const BigUnsigned &a, const BigUnsigned &b) {
return;
} else if (a.len < b.len)
// If a is shorter than b, the result is negative.
+#ifdef FOXIT_CHROME_BUILD
+ abort();
+#else
throw "BigUnsigned::subtract: "
"Negative result in unsigned calculation";
+#endif
// Some variables...
bool borrowIn, borrowOut;
Blk temp;
@@ -223,7 +233,11 @@ void BigUnsigned::subtract(const BigUnsigned &a, const BigUnsigned &b) {
* predictable state. */
if (borrowIn) {
len = 0;
+#ifdef FOXIT_CHROME_BUILD
+ abort();
+#else
throw "BigUnsigned::subtract: Negative result in unsigned calculation";
+#endif
} else
// Copy over the rest of the blocks
for (; i < a.len; i++)
@@ -386,7 +400,11 @@ void BigUnsigned::divideWithRemainder(const BigUnsigned &b, BigUnsigned &q) {
* It would be silly to try to write quotient and remainder to the
* same variable. Rule that out right away. */
if (this == &q)
+#ifdef FOXIT_CHROME_BUILD
+ abort();
+#else
throw "BigUnsigned::divideWithRemainder: Cannot write quotient and remainder into the same variable";
+#endif
/* Now *this and q are separate, so the only concern is that b might be
* aliased to one of them. If so, use a temporary copy of b. */
if (this == &b || &q == &b) {
@@ -596,8 +614,12 @@ void BigUnsigned::bitShiftLeft(const BigUnsigned &a, int b) {
DTRT_ALIASED(this == &a, bitShiftLeft(a, b));
if (b < 0) {
if (b << 1 == 0)
+#ifdef FOXIT_CHROME_BUILD
+ abort();
+#else
throw "BigUnsigned::bitShiftLeft: "
"Pathological shift amount not implemented";
+#endif
else {
bitShiftRight(a, -b);
return;
@@ -622,8 +644,12 @@ void BigUnsigned::bitShiftRight(const BigUnsigned &a, int b) {
DTRT_ALIASED(this == &a, bitShiftRight(a, b));
if (b < 0) {
if (b << 1 == 0)
+#ifdef FOXIT_CHROME_BUILD
+ abort();
+#else
throw "BigUnsigned::bitShiftRight: "
"Pathological shift amount not implemented";
+#endif
else {
bitShiftLeft(a, -b);
return;
@@ -679,7 +705,11 @@ void BigUnsigned::operator ++(int) {
// Prefix decrement
void BigUnsigned::operator --() {
if (len == 0)
+#ifdef FOXIT_CHROME_BUILD
+ abort();
+#else
throw "BigUnsigned::operator --(): Cannot decrement an unsigned zero";
+#endif
Index i;
bool borrow = true;
for (i = 0; borrow; i++) {

Powered by Google App Engine
This is Rietveld 408576698