From commits-return-60317-apmail-harmony-commits-archive=harmony.apache.org@harmony.apache.org Thu Oct 01 20:38:05 2009 Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 51123 invoked from network); 1 Oct 2009 20:38:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Oct 2009 20:38:05 -0000 Received: (qmail 57485 invoked by uid 500); 1 Oct 2009 20:38:04 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 57459 invoked by uid 500); 1 Oct 2009 20:38:04 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 57450 invoked by uid 99); 1 Oct 2009 20:38:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Oct 2009 20:38:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Oct 2009 20:37:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 61E5123888FC; Thu, 1 Oct 2009 20:37:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r820776 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStream.java Date: Thu, 01 Oct 2009 20:37:33 -0000 To: commits@harmony.apache.org From: tellison@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091001203733.61E5123888FC@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tellison Date: Thu Oct 1 20:37:32 2009 New Revision: 820776 URL: http://svn.apache.org/viewvc?rev=820776&view=rev Log: Fix unsafe reference to skipBuf (see http://markmail.org/thread/ixknpr4sb63yhvy6) Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStream.java Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStream.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStream.java?rev=820776&r1=820775&r2=820776&view=diff ============================================================================== --- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStream.java (original) +++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStream.java Thu Oct 1 20:37:32 2009 @@ -211,11 +211,16 @@ } long skipped = 0; int toRead = n < 4096 ? (int) n : 4096; - if (skipBuf == null || skipBuf.length < toRead) { - skipBuf = new byte[toRead]; + // We are unsynchronized, so take a local copy of the skipBuf at some + // point in time. + byte[] localBuf = skipBuf; + if (localBuf == null || localBuf.length < toRead) { + // May be lazily written back to the static. No matter if it + // overwrites somebody else's store. + skipBuf = localBuf = new byte[toRead]; } while (skipped < n) { - int read = read(skipBuf, 0, toRead); + int read = read(localBuf, 0, toRead); if (read == -1) { return skipped; }