Program: 77168
Project: 77168
Buggy source:
/** 
 * Writes two bytes of length information to the output stream in network byte order, followed by the <a href="../../../java/io/DataInput.html#modified-utf-8">modified UTF-8</a> representation of every character in the string <code>s</code>. If <code>s</code> is <code>null</code>, a <code>NullPointerException</code> is thrown.  Each character in the string <code>s</code> is converted to a group of one, two, or three bytes, depending on the value of the character. <p> If a character <code>c</code> is in the range <code>&#92;u0001</code> through <code>&#92;u007f</code>, it is represented by one byte: <p><pre> (byte)c </pre> <p> If a character <code>c</code> is <code>&#92;u0000</code> or is in the range <code>&#92;u0080</code> through <code>&#92;u07ff</code>, then it is represented by two bytes, to be written in the order shown: <p> <pre><code> (byte)(0xc0 | (0x1f &amp; (c &gt;&gt; 6))) (byte)(0x80 | (0x3f &amp; c)) </code></pre> <p> If a character <code>c</code> is in the range <code>&#92;u0800</code> through <code>uffff</code>, then it is represented by three bytes, to be written in the order shown: <p> <pre><code> (byte)(0xe0 | (0x0f &amp; (c &gt;&gt; 12))) (byte)(0x80 | (0x3f &amp; (c &gt;&gt; 6))) (byte)(0x80 | (0x3f &amp; c)) </code></pre> <p> First, the total number of bytes needed to represent all the characters of <code>s</code> is calculated. If this number is larger than <code>65535</code>, then a <code>UTFDataFormatException</code> is thrown. Otherwise, this length is written to the output stream in exactly the manner of the <code>writeShort</code> method; after this, the one-, two-, or three-byte representation of each character in the string <code>s</code> is written. <p> The current byte order setting is ignored. <p> If the bit offset within the stream is non-zero, the remainder of the current byte is padded with 0s and written out first.  The bit offset will be 0 after the write. <p><strong>Note:</strong> This method should not be used in the  implementation of image formats that use standard UTF-8, because  the modified UTF-8 used here is incompatible with standard UTF-8.
 * @param s a <code>String</code> containing the value to bewritten.
 * @exception NullPointerException if <code>s</code> is<code>null</code>.
 * @exception java.io.UTFDataFormatException if the modified UTF-8representation of <code>s</code> requires more than 65536 bytes.
 * @exception IOException if an I/O error occurs.
 */
void writeUTF(String s) throws IOException ;

Fixed version (ground truth):
/** 
 * Writes two bytes of length information to the output stream in network byte order, followed by the <a href="../../../java/io/DataInput.html#modified-utf-8">modified UTF-8</a> representation of every character in the string <code>s</code>. If <code>s</code> is <code>null</code>, a <code>NullPointerException</code> is thrown.  Each character in the string <code>s</code> is converted to a group of one, two, or three bytes, depending on the value of the character. <p> If a character <code>c</code> is in the range <code>&#92;u0001</code> through <code>&#92;u007f</code>, it is represented by one byte: <pre> (byte)c </pre> <p> If a character <code>c</code> is <code>&#92;u0000</code> or is in the range <code>&#92;u0080</code> through <code>&#92;u07ff</code>, then it is represented by two bytes, to be written in the order shown: <pre><code> (byte)(0xc0 | (0x1f &amp; (c &gt;&gt; 6))) (byte)(0x80 | (0x3f &amp; c)) </code></pre> <p> If a character <code>c</code> is in the range <code>&#92;u0800</code> through <code>uffff</code>, then it is represented by three bytes, to be written in the order shown: <pre><code> (byte)(0xe0 | (0x0f &amp; (c &gt;&gt; 12))) (byte)(0x80 | (0x3f &amp; (c &gt;&gt; 6))) (byte)(0x80 | (0x3f &amp; c)) </code></pre> <p> First, the total number of bytes needed to represent all the characters of <code>s</code> is calculated. If this number is larger than <code>65535</code>, then a <code>UTFDataFormatException</code> is thrown. Otherwise, this length is written to the output stream in exactly the manner of the <code>writeShort</code> method; after this, the one-, two-, or three-byte representation of each character in the string <code>s</code> is written. <p> The current byte order setting is ignored. <p> If the bit offset within the stream is non-zero, the remainder of the current byte is padded with 0s and written out first.  The bit offset will be 0 after the write. <p><strong>Note:</strong> This method should not be used in the  implementation of image formats that use standard UTF-8, because  the modified UTF-8 used here is incompatible with standard UTF-8.
 * @param s a <code>String</code> containing the value to bewritten.
 * @exception NullPointerException if <code>s</code> is<code>null</code>.
 * @exception java.io.UTFDataFormatException if the modified UTF-8representation of <code>s</code> requires more than 65536 bytes.
 * @exception IOException if an I/O error occurs.
 */
void writeUTF(String s) throws IOException ;