WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 26c0465

Browse files
committed
prevent typePromotion from running in an endless loop, throw
RuntimeException in such a case
1 parent fad8f43 commit 26c0465

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/main/java/soot/jimple/toolkits/typing/fast/TypeResolver.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,10 @@ public boolean finish() {
383383
final ShortType shortType = ShortType.v();
384384

385385
private ITyping typePromotion(ITyping tg) {
386-
boolean conversionsPending;
386+
int conversionsPending = Integer.MAX_VALUE;
387+
int lastConversionsPending;
387388
do {
389+
lastConversionsPending = conversionsPending;
388390
AugEvalFunction ef = createAugEvalFunction(this.jb);
389391
AugHierarchy h = new AugHierarchy();
390392
UseChecker uc = createUseChecker(this.jb);
@@ -403,16 +405,19 @@ private ITyping typePromotion(ITyping tg) {
403405

404406
} while (uv.typingChanged);
405407

406-
conversionsPending = false;
408+
conversionsPending = 0;
407409
for (Local v : this.jb.getLocals()) {
408410
Type t = tg.get(v);
409411
Type r = convert(t);
410412
if (r != null) {
411413
tg.set(v, r);
412-
conversionsPending = true;
414+
conversionsPending++;
413415
}
414416
}
415-
} while (conversionsPending);
417+
if (lastConversionsPending <= conversionsPending) {
418+
throw new RuntimeException("typePromotion failed: conversionsPending was not reduced " + jb.getMethod());
419+
}
420+
} while (conversionsPending > 0);
416421

417422
return tg;
418423
}

0 commit comments

Comments
 (0)