mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
Merge
This commit is contained in:
commit
a8c5f1e59a
64 changed files with 1781 additions and 378 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -31,6 +31,7 @@ package java.math;
|
|||
|
||||
import static java.math.BigInteger.LONG_MASK;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Immutable, arbitrary-precision signed decimal numbers. A
|
||||
|
@ -424,9 +425,14 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
|||
* @since 1.5
|
||||
*/
|
||||
public BigDecimal(char[] in, int offset, int len, MathContext mc) {
|
||||
// protect against huge length.
|
||||
if (offset + len > in.length || offset < 0)
|
||||
throw new NumberFormatException("Bad offset or len arguments for char[] input.");
|
||||
// protect against huge length, negative values, and integer overflow
|
||||
try {
|
||||
Objects.checkFromIndexSize(offset, len, in.length);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
throw new NumberFormatException
|
||||
("Bad offset or len arguments for char[] input.");
|
||||
}
|
||||
|
||||
// This is the primary string to BigDecimal constructor; all
|
||||
// incoming strings end up here; it uses explicit (inline)
|
||||
// parsing for speed and generates at most one intermediate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue