Skip to content

Commit 5ec53c0

Browse files
committed
Cap btcToSats to prevent overflow errors
1 parent c5c00a5 commit 5ec53c0

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

qml/bitcoinamount.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include <qml/bitcoinamount.h>
66

7+
#include <limits>
8+
79
#include <QRegularExpression>
810
#include <QStringList>
911

@@ -131,6 +133,10 @@ qint64 BitcoinAmount::btcToSats(const QString& btcSanitized)
131133
frac = parts[1].leftJustified(8, '0').toLongLong();
132134
}
133135

136+
if (whole > std::numeric_limits<qint64>::max() / COIN) {
137+
return std::numeric_limits<qint64>::max();
138+
}
139+
134140
return whole * COIN + frac;
135141
}
136142

0 commit comments

Comments
 (0)