Commit 8710d8b 1 parent ce190f1 commit 8710d8b Copy full SHA for 8710d8b
File tree 13 files changed +51
-17
lines changed
13 files changed +51
-17
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,9 @@ public MethodToContexts(Iterator<MethodOrMethodContext> it) {
55
55
public void add (Iterator <MethodOrMethodContext > it ) {
56
56
while (it .hasNext ()) {
57
57
MethodOrMethodContext momc = it .next ();
58
- add (momc );
58
+ if (momc != null ) {
59
+ add (momc );
60
+ }
59
61
}
60
62
}
61
63
Original file line number Diff line number Diff line change @@ -104,11 +104,14 @@ public void build() {
104
104
}
105
105
while (callEdges .hasNext ()) {
106
106
Edge e = callEdges .next ();
107
+ if (e == null ) {
108
+ continue ;
109
+ }
107
110
if (!e .isInvalid ()) {
108
111
if (e .tgt ().isConcrete () || e .tgt ().isNative ()) {
109
- MethodPAG mpag = MethodPAG .v (pag , e .tgt ());
110
- mpag .build ();
111
- mpag .addToPAG (null );
112
+ MethodPAG mpag = MethodPAG .v (pag , e .tgt ());
113
+ mpag .build ();
114
+ mpag .addToPAG (null );
112
115
}
113
116
pag .addCallTarget (e );
114
117
}
Original file line number Diff line number Diff line change @@ -359,7 +359,11 @@ private void preprocess() {
359
359
CallGraph soot_callgraph = Scene .v ().getCallGraph ();
360
360
361
361
while (smList .hasNext ()) {
362
- final SootMethod func = smList .next ().method ();
362
+ MethodOrMethodContext n = smList .next ();
363
+ if (n == null ) {
364
+ continue ;
365
+ }
366
+ final SootMethod func = n .method ();
363
367
func2int .put (func , id );
364
368
int2func .put (id , func );
365
369
@@ -385,7 +389,7 @@ private void preprocess() {
385
389
QueueReader <Edge > edgeList = Scene .v ().getCallGraph ().listener ();
386
390
while (edgeList .hasNext ()) {
387
391
Edge edge = edgeList .next ();
388
- if (edge .isClinit ()) {
392
+ if (edge == null || edge .isClinit ()) {
389
393
continue ;
390
394
}
391
395
Original file line number Diff line number Diff line change @@ -115,6 +115,9 @@ final public BitVector get(Type type) {
115
115
final Scene sc = Scene .v ();
116
116
while (allocNodeListener .hasNext ()) {
117
117
AllocNode n = allocNodeListener .next ();
118
+ if (n == null ) {
119
+ continue ;
120
+ }
118
121
Type nt = n .getType ();
119
122
Iterable <Type > types ;
120
123
if (nt instanceof NullType || nt instanceof AnySubType ) {
Original file line number Diff line number Diff line change @@ -111,6 +111,9 @@ private void processReachables() {
111
111
reachableMethods .update ();
112
112
while (reachablesReader .hasNext ()) {
113
113
MethodOrMethodContext m = reachablesReader .next ();
114
+ if (m == null ) {
115
+ continue ;
116
+ }
114
117
MethodPAG mpag = MethodPAG .v (pag , m .method ());
115
118
try {
116
119
mpag .build ();
@@ -129,6 +132,9 @@ private void processReachables() {
129
132
private void processCallEdges () {
130
133
while (callEdges .hasNext ()) {
131
134
Edge e = callEdges .next ();
135
+ if (e == null ) {
136
+ continue ;
137
+ }
132
138
MethodPAG amp = MethodPAG .v (pag , e .tgt ());
133
139
amp .build ();
134
140
amp .addToPAG (e .tgtCtxt ());
Original file line number Diff line number Diff line change 29
29
import java .util .LinkedHashMap ;
30
30
import java .util .LinkedHashSet ;
31
31
import java .util .Map ;
32
+ import java .util .NoSuchElementException ;
32
33
import java .util .Set ;
33
34
34
35
import soot .Kind ;
@@ -99,7 +100,7 @@ public boolean removeAllEdgesOutOf(Unit u) {
99
100
Set <Edge > edgesToRemove = new HashSet <>();
100
101
for (QueueReader <Edge > edgeRdr = listener (); edgeRdr .hasNext ();) {
101
102
Edge e = edgeRdr .next ();
102
- if (e .srcUnit () == u ) {
103
+ if (e != null && e .srcUnit () == u ) {
103
104
e .remove ();
104
105
removeEdge (e , false );
105
106
edgesToRemove .add (e );
@@ -395,7 +396,9 @@ public String toString() {
395
396
StringBuilder out = new StringBuilder ();
396
397
for (QueueReader <Edge > reader = listener (); reader .hasNext ();) {
397
398
Edge e = reader .next ();
398
- out .append (e .toString ()).append ('\n' );
399
+ if (e != null ) {
400
+ out .append (e .toString ()).append ('\n' );
401
+ }
399
402
}
400
403
return out .toString ();
401
404
}
Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ public void build() {
111
111
break ;
112
112
}
113
113
final MethodOrMethodContext momc = worklist .next ();
114
- if (!process (momc )) {
114
+ if (momc != null && !process (momc )) {
115
115
break ;
116
116
}
117
117
}
Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ public Iterator<Edge> wrap(Iterator<Edge> source) {
48
48
private void advance () {
49
49
while (source .hasNext ()) {
50
50
next = source .next ();
51
+ if (next == null ) {
52
+ continue ;
53
+ }
51
54
if (pred .want (next )) {
52
55
return ;
53
56
}
Original file line number Diff line number Diff line change @@ -279,6 +279,9 @@ public void processReachables() {
279
279
}
280
280
}
281
281
MethodOrMethodContext momc = worklist .next ();
282
+ if (momc == null ) {
283
+ continue ;
284
+ }
282
285
SootMethod m = momc .method ();
283
286
if (appOnly && !m .getDeclaringClass ().isApplicationClass ()) {
284
287
continue ;
Original file line number Diff line number Diff line change 25
25
import java .util .Collection ;
26
26
import java .util .HashSet ;
27
27
import java .util .Iterator ;
28
+ import java .util .NoSuchElementException ;
28
29
import java .util .Set ;
29
30
30
31
import soot .MethodOrMethodContext ;
@@ -89,6 +90,9 @@ public void update() {
89
90
}
90
91
while (unprocessedMethods .hasNext ()) {
91
92
MethodOrMethodContext m = unprocessedMethods .next ();
93
+ if (m == null ) {
94
+ continue ;
95
+ }
92
96
Iterator <Edge > targets = cg .edgesOutOf (m );
93
97
if (filter != null ) {
94
98
targets = filter .wrap (targets );
Original file line number Diff line number Diff line change @@ -134,7 +134,9 @@ public String toString() {
134
134
StringBuilder out = new StringBuilder ();
135
135
for (QueueReader <Edge > rdr = listener (); rdr .hasNext ();) {
136
136
Edge e = rdr .next ();
137
- out .append (e .toString ()).append ('\n' );
137
+ if (e != null ) {
138
+ out .append (e .toString ()).append ('\n' );
139
+ }
138
140
}
139
141
return out .toString ();
140
142
}
Original file line number Diff line number Diff line change 33
33
@ SuppressWarnings ("unchecked" )
34
34
public class ChunkedQueue <E > {
35
35
36
- protected static final Object NULL_CONST = new Object ();
37
36
protected static final Object DELETED_CONST = new Object ();
38
37
39
38
protected static final int LENGTH = 60 ;
@@ -48,7 +47,7 @@ public ChunkedQueue() {
48
47
/** Add an object to the queue. */
49
48
public void add (E o ) {
50
49
if (o == null ) {
51
- o = ( E ) NULL_CONST ;
50
+ throw new IllegalArgumentException ( "Null is not allowed" ) ;
52
51
}
53
52
if (index == LENGTH - 1 ) {
54
53
Object [] temp = new Object [LENGTH ];
Original file line number Diff line number Diff line change 35
35
* been read by all the QueueReader's are kept. A QueueReader only receives the Object's added to the queue <b>after</b> the
36
36
* QueueReader was created.
37
37
*
38
+ * This QueueReader does <emph>not</emph> accept <code>null</code> values.
38
39
* @author Ondrej Lhotak
39
40
*/
40
41
public class QueueReader <E > implements java .util .Iterator <E > {
@@ -54,19 +55,20 @@ public E next() {
54
55
Object ret = null ;
55
56
do {
56
57
if (q [index ] == null ) {
57
- throw new NoSuchElementException ();
58
+ //this is the case when someone concurrently invalidates
59
+ //the rest of the elements
60
+ return null ;
58
61
}
59
62
if (index == q .length - 1 ) {
60
63
q = (E []) q [index ];
61
64
index = 0 ;
62
65
if (q [index ] == null ) {
63
- throw new NoSuchElementException ();
66
+ //this is the case when someone concurrently invalidates
67
+ //the rest of the elements
68
+ return null ;
64
69
}
65
70
}
66
71
ret = q [index ];
67
- if (ret == ChunkedQueue .NULL_CONST ) {
68
- ret = null ;
69
- }
70
72
index ++;
71
73
} while (skip (ret ));
72
74
return (E ) ret ;
You can’t perform that action at this time.
0 commit comments