BUG: Fixing case in which the pointer the data buffers doesn't
authorLuis Ibanez <luis.ibanez@gmail.com>
Fri, 20 Aug 2010 21:33:43 +0000 (21:33 +0000)
committerLuis Ibanez <luis.ibanez@gmail.com>
Fri, 20 Aug 2010 21:33:43 +0000 (21:33 +0000)
     get positioned at the beginning of the buffer after a new
     buffer load. This case only happens when the pointer happens
     to be at the end of the buffer when the request for the new
     block arrives.  Fix contributed by Bill Hoffman.

libopenjpeg/cio.c

index 05c7101c95fa2c05e85e0275e3e04ee9df8959c6..fd914ad04093ac3cdef87ae6fa08ce859773dd43 100644 (file)
@@ -406,6 +406,14 @@ OPJ_UINT32 opj_stream_read_data (opj_stream_private_t * p_stream,OPJ_BYTE * p_bu
                p_stream->m_byte_offset += p_stream->m_bytes_in_buffer;
                p_stream->m_bytes_in_buffer = 0;
        }
+  else
+  {
+    /* case where we are already at the end of the buffer
+       so reset the m_current_data to point to the start of the
+       stored buffer to get ready to read from disk*/
+    p_stream->m_current_data = p_stream->m_stored_data;
+  }
+
 
        while
                (true)