|
From: <br...@us...> - 2010-05-28 15:17:23
|
Revision: 4150
http://openvrml.svn.sourceforge.net/openvrml/?rev=4150&view=rev
Author: braden
Date: 2010-05-28 15:17:16 +0000 (Fri, 28 May 2010)
Log Message:
-----------
Use jpeg_decompress_struct.out_color_components to determine the scan line buffer size. This addresses a memory corruption issue when reading grayscale JPEGs.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/node/vrml97/image_stream_listener.cpp
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2010-05-27 16:32:54 UTC (rev 4149)
+++ trunk/ChangeLog 2010-05-28 15:17:16 UTC (rev 4150)
@@ -1,3 +1,17 @@
+2010-05-28 Braden McDaniel <br...@en...>
+
+ Use jpeg_decompress_struct.out_color_components to determine the
+ scan line buffer size. This addresses a memory corruption issue
+ when reading grayscale JPEGs.
+
+ * src/node/vrml97/image_stream_listener.cpp
+ (openvrml_node_vrml97::image_stream_listener::jpeg_reader::do_read(const
+ std::vector<unsigned char> &)): Use
+ jpeg_decompress_struct.out_color_components to determine the scan
+ line buffer size. This member isn't set until after the call to
+ jpeg_start_decompress; so move the buffer allocation to the
+ start_decompress section.
+
2010-05-27 Braden McDaniel <br...@en...>
FcFini cannot be called safely from library code. Calling it is
Modified: trunk/src/node/vrml97/image_stream_listener.cpp
===================================================================
--- trunk/src/node/vrml97/image_stream_listener.cpp 2010-05-27 16:32:54 UTC (rev 4149)
+++ trunk/src/node/vrml97/image_stream_listener.cpp 2010-05-28 15:17:16 UTC (rev 4150)
@@ -458,16 +458,6 @@
image.comp(this->cinfo_.num_components);
image.resize(this->cinfo_.image_width, this->cinfo_.image_height);
- const JDIMENSION samples_per_row =
- this->cinfo_.output_width * this->cinfo_.num_components;
- static const JDIMENSION num_rows = 1;
- this->scanlines =
- (*this->cinfo_.mem->alloc_sarray)(
- reinterpret_cast<j_common_ptr>(&this->cinfo_),
- JPOOL_IMAGE,
- samples_per_row,
- num_rows);
-
this->decoder_state = jpeg_reader::start_decompress;
}
case jpeg_reader::start_decompress:
@@ -482,6 +472,16 @@
return; // Input suspended.
}
+ const JDIMENSION samples_per_row =
+ this->cinfo_.output_width * this->cinfo_.out_color_components;
+ static const JDIMENSION num_rows = 1;
+ this->scanlines =
+ (*this->cinfo_.mem->alloc_sarray)(
+ reinterpret_cast<j_common_ptr>(&this->cinfo_),
+ JPOOL_IMAGE,
+ samples_per_row,
+ num_rows);
+
this->decoder_state = this->cinfo_.buffered_image
? jpeg_reader::decompress_progressive
: jpeg_reader::decompress_sequential;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|