diff options
| author | 2015-11-12 16:53:41 -0800 | |
|---|---|---|
| committer | 2015-11-12 17:31:09 -0800 | |
| commit | 952d608062eec2d7f47f9b45dba935ad8b4d23e5 (patch) | |
| tree | 6acb2a889c38a76d70771d42c4dfe3ac53116424 /test/061-out-of-memory/src/Main.java | |
| parent | efca362e8c67d5b330dd4ebc312cd45cf2585964 (diff) | |
Add missing null check to String::ToCharArray
Added test.
Bug: 25641543
Change-Id: Ic9a21ce8bc530dbedf14334ad47f5faa90ae4ddc
Diffstat (limited to 'test/061-out-of-memory/src/Main.java')
| -rw-r--r-- | test/061-out-of-memory/src/Main.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/061-out-of-memory/src/Main.java b/test/061-out-of-memory/src/Main.java index c812c81114..52373d3c5f 100644 --- a/test/061-out-of-memory/src/Main.java +++ b/test/061-out-of-memory/src/Main.java @@ -26,6 +26,7 @@ public class Main { testHugeArray(); testOomeLarge(); testOomeSmall(); + testOomeToCharArray(); System.out.println("tests succeeded"); } @@ -106,4 +107,22 @@ public class Main { } System.out.println("testOomeSmall succeeded"); } + + private static void testOomeToCharArray() { + Object[] o = new Object[1000000]; + String test = "test"; + int i = 0; + try { + for (; i < o.length; ++i) o[i] = new char[1000000]; + } catch (OutOfMemoryError oom) {} + try { + for (; i < o.length; ++i) o[i] = new Object(); + } catch (OutOfMemoryError oom) {} + try { + test.toCharArray(); + } catch (OutOfMemoryError oom) { + o = null; + System.out.println("Got expected toCharArray OOM"); + } + } } |