diff options
author | wisberg <wisberg> | 2003-04-19 07:16:57 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2003-04-19 07:16:57 +0000 |
commit | 7fbdd52e8f5a4a24aa56468612a718b2ada7bf6f (patch) | |
tree | 640a22fe7c2a932ac28b6a83d23eafd7b4b22497 /runtime | |
parent | 5e4671ab839f3eea6a2747c0295a1b76472412ac (diff) | |
download | aspectj-7fbdd52e8f5a4a24aa56468612a718b2ada7bf6f.tar.gz aspectj-7fbdd52e8f5a4a24aa56468612a718b2ada7bf6f.zip |
prevent div/0, NPE (by inspection)
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/src/org/aspectj/runtime/internal/CFlowStack.java | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/src/org/aspectj/runtime/internal/CFlowStack.java b/runtime/src/org/aspectj/runtime/internal/CFlowStack.java index d6a4541a4..067860ce7 100644 --- a/runtime/src/org/aspectj/runtime/internal/CFlowStack.java +++ b/runtime/src/org/aspectj/runtime/internal/CFlowStack.java @@ -39,7 +39,8 @@ public class CFlowStack { } change_count++; // Collect more often if there are many threads, but not *too* often - if (change_count > Math.max(MIN_COLLECT_AT, COLLECT_AT/stacks.size())) { + int size = Math.max(1, stacks.size()); // should be >1 b/c always live threads, but... + if (change_count > Math.max(MIN_COLLECT_AT, COLLECT_AT/size)) { Stack dead_stacks = new Stack(); for (Enumeration e = stacks.keys(); e.hasMoreElements(); ) { Thread t = (Thread)e.nextElement(); @@ -79,7 +80,8 @@ public class CFlowStack { } public Object get(int index) { - return peekCFlow().get(index); + CFlow cf = peekCFlow(); + return (null == cf ? null : cf.get(index)); } public Object peekInstance() { |