Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit 1da978d

Browse files
author
Pavel Rappo
committedAug 19, 2020
8251357: [DocCommentParser] Infinite loop while looking for the end of a preamble
Reviewed-by: jjg
1 parent 8eed9aa commit 1da978d

File tree

6 files changed

+65
-5
lines changed

6 files changed

+65
-5
lines changed
 

‎src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -708,14 +708,14 @@ boolean isEndPreamble() {
708708
case "body":
709709
// Check if also followed by <main>
710710
// 1. skip rest of <body>
711-
while (ch != -1 && ch != '>') {
711+
while (bp < buflen && ch != '>') {
712712
nextChar();
713713
}
714714
if (ch == '>') {
715715
nextChar();
716716
}
717717
// 2. skip any whitespace
718-
while (ch != -1 && Character.isWhitespace(ch)) {
718+
while (bp < buflen && isWhitespace(ch)) {
719719
nextChar();
720720
}
721721
// 3. check if looking at "<main..."

‎test/langtools/tools/javac/doctree/dcapi/DocCommentTreeApiTester.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
2323

2424
/*
2525
* @test
26-
* @bug 8132096 8157611 8190552
26+
* @bug 8132096 8157611 8190552 8251357
2727
* @summary test the APIs in the DocTree interface
2828
* @modules jdk.compiler/com.sun.tools.javac.api
2929
* jdk.compiler/com.sun.tools.javac.file
@@ -53,7 +53,6 @@
5353
import javax.lang.model.util.Elements;
5454
import javax.tools.FileObject;
5555
import javax.tools.JavaFileObject;
56-
import javax.tools.JavaFileObject.Kind;
5756
import javax.tools.StandardJavaFileManager;
5857

5958
import com.sun.source.doctree.DocTree;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!-- /nodynamiccopyright/ -->
2+
<HTML>
3+
<HEAD>
4+
</HEAD>
5+
<BODY lang="en"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
EXPECT_START
2+
DocComment[DOC_COMMENT, pos:0
3+
preamble: 5
4+
Comment[COMMENT, pos:0, <!--_/nodynamiccopyright/_-->]
5+
StartElement[START_ELEMENT, pos:30
6+
name:HTML
7+
attributes: empty
8+
]
9+
StartElement[START_ELEMENT, pos:37
10+
name:HEAD
11+
attributes: empty
12+
]
13+
EndElement[END_ELEMENT, pos:44, HEAD]
14+
Erroneous[ERRONEOUS, pos:52
15+
code: compiler.err.dc.malformed.html
16+
body: <
17+
]
18+
firstSentence: 1
19+
Text[TEXT, pos:53, BODY_lang="en"]
20+
body: empty
21+
block tags: empty
22+
]
23+
EXPECT_END
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!-- /nodynamiccopyright/ -->
2+
<HTML>
3+
<HEAD>
4+
</HEAD>
5+
<BODY lang="en">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
EXPECT_START
2+
DocComment[DOC_COMMENT, pos:0
3+
preamble: 5
4+
Comment[COMMENT, pos:0, <!--_/nodynamiccopyright/_-->]
5+
StartElement[START_ELEMENT, pos:30
6+
name:HTML
7+
attributes: empty
8+
]
9+
StartElement[START_ELEMENT, pos:37
10+
name:HEAD
11+
attributes: empty
12+
]
13+
EndElement[END_ELEMENT, pos:44, HEAD]
14+
StartElement[START_ELEMENT, pos:52
15+
name:BODY
16+
attributes: 1
17+
Attribute[ATTRIBUTE, pos:58
18+
name: lang
19+
vkind: DOUBLE
20+
value: 1
21+
Text[TEXT, pos:64, en]
22+
]
23+
]
24+
firstSentence: empty
25+
body: empty
26+
block tags: empty
27+
]
28+
EXPECT_END

0 commit comments

Comments
 (0)
This repository has been archived.