This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new 642badb Avoid NPEs
642badb is described below
commit 642badb1d7a684d3707c594bb37344aa30d907fc
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Apr 7 16:06:18 2021 +0100
Avoid NPEs
---
java/org/apache/coyote/http2/Stream.java | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/java/org/apache/coyote/http2/Stream.java
b/java/org/apache/coyote/http2/Stream.java
index efb2cca..00d2f97 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -1028,8 +1028,19 @@ class Stream extends AbstractNonZeroStream implements
HeaderEmitter {
int written = -1;
+ // It is still possible that the stream has been closed and
inBuffer
+ // set to null between the call to ensureBuffersExist() above and
+ // the sync below. The checks just before and just inside the sync
+ // ensure we don't get any NPEs reported.
+ ByteBuffer tmpInBuffer = inBuffer;
+ if (tmpInBuffer == null) {
+ return -1;
+ }
// Ensure that only one thread accesses inBuffer at a time
- synchronized (inBuffer) {
+ synchronized (tmpInBuffer) {
+ if (inBuffer == null) {
+ return -1;
+ }
boolean canRead = false;
while (inBuffer.position() == 0 && (canRead = isActive() &&
!isInputFinished())) {
// Need to block until some data is written
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]