From bc372054e29ff41d697a822b9b9388daf90208da Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Wed, 22 Aug 2018 20:34:38 +0000 Subject: [PATCH] Tweaked Java QrCode.toSvgString() to avoid overflow entirely. --- java/io/nayuki/qrcodegen/QrCode.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/java/io/nayuki/qrcodegen/QrCode.java b/java/io/nayuki/qrcodegen/QrCode.java index e596001..06f6929 100644 --- a/java/io/nayuki/qrcodegen/QrCode.java +++ b/java/io/nayuki/qrcodegen/QrCode.java @@ -280,14 +280,12 @@ public final class QrCode { public String toSvgString(int border) { if (border < 0) throw new IllegalArgumentException("Border must be non-negative"); - if (size + border * 2L > Integer.MAX_VALUE) - throw new IllegalArgumentException("Border too large"); - + long brd = border; StringBuilder sb = new StringBuilder() .append("\n") .append("\n") .append(String.format("\n", - size + border * 2)) + size + brd * 2)) .append("\t\n") .append("\t