From: wisberg Date: Sat, 19 Apr 2003 07:16:57 +0000 (+0000) Subject: prevent div/0, NPE (by inspection) X-Git-Tag: V1_1_0_RC2~170 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7fbdd52e8f5a4a24aa56468612a718b2ada7bf6f;p=aspectj.git prevent div/0, NPE (by inspection) --- 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() {