Skip to content

Commit

Permalink
Double check size to avoid ArrayIndexOutOfBoundsException (netty#…
Browse files Browse the repository at this point in the history
…9609)

Motivation:

Recycler$Stack.pop will occurs `ArrayIndexOutOfBoundsException` in some race cases, we should double check `size` even after `scavenge` called.

Modifications:

Double check `size` after `scavenge`

Result:

avoid ArrayIndexOutOfBoundsException in `pop`
  • Loading branch information
carryxyh authored and normanmaurer committed Sep 26, 2019
1 parent 92941cd commit 3ef00ea
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions common/src/main/java/io/netty/util/Recycler.java
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,10 @@ DefaultHandle<T> pop() {
return null;
}
size = this.size;
if (size <= 0) {
// double check, avoid races
return null;
}
}
size --;
DefaultHandle ret = elements[size];
Expand Down

0 comments on commit 3ef00ea

Please sign in to comment.