[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash/libbase zlib_adapter.cpp
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash/libbase zlib_adapter.cpp |
Date: |
Mon, 03 Dec 2007 12:36:26 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/12/03 12:36:26
Modified files:
libbase : zlib_adapter.cpp
Log message:
print error messages from zlib, few more checks for robustness.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/zlib_adapter.cpp?cvsroot=gnash&r1=1.19&r2=1.20
Patches:
Index: zlib_adapter.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/zlib_adapter.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- zlib_adapter.cpp 30 Oct 2007 18:55:41 -0000 1.19
+++ zlib_adapter.cpp 3 Dec 2007 12:36:26 -0000 1.20
@@ -95,9 +95,13 @@
}
- void reset()
// Discard current results and rewind to the beginning.
// Necessary in order to seek backwards.
+ //
+ // might throw a ParserException if unable to reset the
uderlying
+ // stream to original position.
+ //
+ void reset()
{
m_error = 0;
m_at_eof = 0;
@@ -115,7 +119,12 @@
m_zstream.avail_out = 0;
// Rewind the underlying stream.
- m_in->set_position(m_initial_stream_pos);
+ if ( m_in->set_position(m_initial_stream_pos) ==
TU_FILE_SEEK_ERROR )
+ {
+ std::stringstream ss;
+ ss << "inflater_impl::reset: unable to seek
underlying stream to position " << m_initial_stream_pos;
+ throw gnash::ParserException(ss.str());
+ }
m_logical_stream_pos = m_initial_stream_pos;
}
@@ -125,10 +134,9 @@
{
using gnash::ParserException;
- if (m_error)
- {
- return 0;
- }
+ assert(bytes);
+
+ if (m_error) return 0;
m_zstream.next_out = (unsigned char*) dst;
m_zstream.avail_out = bytes;
@@ -159,26 +167,31 @@
}
if (err == Z_BUF_ERROR)
{
-
//gnash::log_error("inflater_impl::inflate_from_stream() inflate() returned
Z_BUF_ERROR");
+ std::stringstream ss;
+ ss << __FILE__ << ":" << __LINE__ << ":
" << m_zstream.msg;
// we should call inflate again...
giving more input or output space !
- //m_error = 1;
+ gnash::log_error("%s",
ss.str().c_str());
break;
}
if (err == Z_DATA_ERROR)
{
- throw ParserException("Data error
inflating input");
+ std::stringstream ss;
+ ss << __FILE__ << ":" << __LINE__ << ":
" << m_zstream.msg;
+ throw ParserException(ss.str());
break;
}
if (err == Z_MEM_ERROR)
{
- throw ParserException("Memory error
inflating input");
+ std::stringstream ss;
+ ss << __FILE__ << ":" << __LINE__ << ":
" << m_zstream.msg;
+ throw ParserException(ss.str());
break;
}
if (err != Z_OK)
{
// something's wrong.
std::stringstream ss;
- ss <<
"inflater_impl::inflate_from_stream() inflate() returned " << err;
+ ss << __FILE__ << ":" << __LINE__ << ":
" << m_zstream.msg;
throw ParserException(ss.str());
//m_error = 1;
break;
@@ -256,6 +269,7 @@
// If we're seeking backwards, then restart from the beginning.
if (pos < inf->m_logical_stream_pos)
{
+ log_debug("inflater reset due to seek back");
inf->reset();
}
@@ -265,6 +279,7 @@
while (inf->m_logical_stream_pos < pos)
{
int to_read = pos - inf->m_logical_stream_pos;
+ assert(to_read > 0);
int to_read_this_time = imin(to_read, ZBUF_SIZE);
assert(to_read_this_time > 0);
- [Gnash-commit] gnash/libbase zlib_adapter.cpp,
Sandro Santilli <=