diff options
author | Patrick Scott <phanna@android.com> | 2009-10-19 12:49:07 -0400 |
---|---|---|
committer | Patrick Scott <phanna@android.com> | 2009-10-19 13:04:08 -0400 |
commit | 169ef4cca30c77a1a85c9684560c504a5ac230b5 (patch) | |
tree | c2982b14b95b1bd07331838a584227c7b1bfe0b0 /core/java/android/webkit/ByteArrayBuilder.java | |
parent | 208360b22db7bdd940a7005fd44135e8916742af (diff) | |
download | frameworks_base-169ef4cca30c77a1a85c9684560c504a5ac230b5.zip frameworks_base-169ef4cca30c77a1a85c9684560c504a5ac230b5.tar.gz frameworks_base-169ef4cca30c77a1a85c9684560c504a5ac230b5.tar.bz2 |
Check for null before returing a chunk from the pool.
Since references can be queued in another thread, the first entry in the pool
could have been queued after processPoolLocked. Check for null and create a new
chunk if the check fails.
Diffstat (limited to 'core/java/android/webkit/ByteArrayBuilder.java')
-rw-r--r-- | core/java/android/webkit/ByteArrayBuilder.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/core/java/android/webkit/ByteArrayBuilder.java b/core/java/android/webkit/ByteArrayBuilder.java index d32a962..334526b 100644 --- a/core/java/android/webkit/ByteArrayBuilder.java +++ b/core/java/android/webkit/ByteArrayBuilder.java @@ -114,14 +114,17 @@ class ByteArrayBuilder { length = DEFAULT_CAPACITY; } synchronized (sPool) { - // Process any queued references so that sPool does not contain - // dead entries. + // Process any queued references and remove them from the pool. processPoolLocked(); if (!sPool.isEmpty()) { - return sPool.removeFirst().get(); - } else { - return new Chunk(length); + Chunk c = sPool.removeFirst().get(); + // The first item may have been queued after processPoolLocked + // so check for null. + if (c != null) { + return c; + } } + return new Chunk(length); } } |