gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/swf/tag_loaders.cpp


From: Sandro Santilli
Subject: [Gnash-commit] gnash ChangeLog server/swf/tag_loaders.cpp
Date: Wed, 01 Aug 2007 21:03:13 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Sandro Santilli <strk>  07/08/01 21:03:12

Modified files:
        .              : ChangeLog 
        server/swf     : tag_loaders.cpp 

Log message:
                * server/swf/tag_loaders.cpp (sound_expand): fix assertion
                  checking; added some uses of the new stream::ensureBytes() 
method;
                  add more scoped_array uses.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3903&r2=1.3904
http://cvs.savannah.gnu.org/viewcvs/gnash/server/swf/tag_loaders.cpp?cvsroot=gnash&r1=1.118&r2=1.119

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.3903
retrieving revision 1.3904
diff -u -b -r1.3903 -r1.3904
--- ChangeLog   1 Aug 2007 20:28:00 -0000       1.3903
+++ ChangeLog   1 Aug 2007 21:03:12 -0000       1.3904
@@ -1,5 +1,11 @@
 2007-08-01 Sandro Santilli <address@hidden>
 
+       * server/swf/tag_loaders.cpp (sound_expand): fix assertion
+         checking; added some uses of the new stream::ensureBytes() method;
+         add more scoped_array uses.
+
+2007-08-01 Sandro Santilli <address@hidden>
+
        * server/stream.h: add ensureBytes() method to verify
          SWF integrity.
 

Index: server/swf/tag_loaders.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/swf/tag_loaders.cpp,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -b -r1.118 -r1.119
--- server/swf/tag_loaders.cpp  1 Aug 2007 18:57:03 -0000       1.118
+++ server/swf/tag_loaders.cpp  1 Aug 2007 21:03:12 -0000       1.119
@@ -17,7 +17,7 @@
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 //
 
-/* $Id: tag_loaders.cpp,v 1.118 2007/08/01 18:57:03 strk Exp $ */
+/* $Id: tag_loaders.cpp,v 1.119 2007/08/01 21:03:12 strk Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -413,6 +413,8 @@
     // tags 20 || 36
     assert(tag == SWF::DEFINELOSSLESS || tag == SWF::DEFINELOSSLESS2);
 
+    in->ensureBytes(16+16+16+8); // the initial header 
+
     uint16_t   character_id = in->read_u16();
     uint8_t    bitmap_format = in->read_u8();  // 3 == 8 bit, 4 == 16 bit, 5 
== 32 bit
     uint16_t   width = in->read_u16();
@@ -425,6 +427,8 @@
                  tag, character_id, bitmap_format, width, height);
     );
 
+    // TODO: there's a lot of duplicated code in this function, we should 
clean it up
+
     //bitmap_info*     bi = NULL;
     if (m->get_create_bitmaps() == DO_LOAD_BITMAPS)
     {
@@ -434,6 +438,7 @@
 #else
        if (tag == SWF::DEFINELOSSLESS) // 20
        {
+
            // RGB image data.
            std::auto_ptr<image::rgb> image ( image::create_rgb(width, height) 
);
 
@@ -442,22 +447,24 @@
                // 8-bit data, preceded by a palette.
 
                const int bytes_per_pixel = 1;
+
+               in->ensureBytes(1); // color table size
                int color_table_size = in->read_u8();
                color_table_size++;     // !! SWF stores one less than the 
actual size
 
                int pitch = (width * bytes_per_pixel + 3) & ~3;
 
                int buffer_bytes = color_table_size * 3 + pitch * height;
-               uint8_t* buffer = new uint8_t[buffer_bytes];
+               boost::scoped_array<uint8_t> buffer ( new uint8_t[buffer_bytes] 
);
 
-               inflate_wrapper(in->get_underlying_stream(), buffer, 
buffer_bytes);
+               inflate_wrapper(in->get_underlying_stream(), buffer.get(), 
buffer_bytes);
                assert(in->get_position() <= in->get_tag_end_position());
 
-               uint8_t* color_table = buffer;
+               uint8_t* color_table = buffer.get();
 
                for (int j = 0; j < height; j++)
                {
-                   uint8_t*    image_in_row = buffer + color_table_size * 3 + 
j * pitch;
+                   uint8_t*    image_in_row = buffer.get() + color_table_size 
* 3 + j * pitch;
                    uint8_t*    image_out_row = image::scanline(image.get(), j);
                    for (int i = 0; i < width; i++)
                    {
@@ -468,7 +475,6 @@
                    }
                }
 
-               delete [] buffer;
            }
            else if (bitmap_format == 4)
            {
@@ -477,14 +483,14 @@
                int pitch = (width * bytes_per_pixel + 3) & ~3;
 
                int buffer_bytes = pitch * height;
-               uint8_t* buffer = new uint8_t[buffer_bytes];
+               boost::scoped_array<uint8_t> buffer ( new uint8_t[buffer_bytes] 
);
 
-               inflate_wrapper(in->get_underlying_stream(), buffer, 
buffer_bytes);
+               inflate_wrapper(in->get_underlying_stream(), buffer.get(), 
buffer_bytes);
                assert(in->get_position() <= in->get_tag_end_position());
 
                for (int j = 0; j < height; j++)
                {
-                   uint8_t*    image_in_row = buffer + j * pitch;
+                   uint8_t*    image_in_row = buffer.get() + j * pitch;
                    uint8_t*    image_out_row = image::scanline(image.get(), j);
                    for (int i = 0; i < width; i++)
                    {
@@ -497,7 +503,6 @@
                    }
                }
 
-               delete [] buffer;
            }
            else if (bitmap_format == 5)
            {
@@ -506,15 +511,15 @@
                int pitch = width * bytes_per_pixel;
 
                int buffer_bytes = pitch * height;
-               uint8_t* buffer = new uint8_t[buffer_bytes];
+               boost::scoped_array<uint8_t> buffer ( new uint8_t[buffer_bytes] 
);
 
-               inflate_wrapper(in->get_underlying_stream(), buffer, 
buffer_bytes);
+               inflate_wrapper(in->get_underlying_stream(), buffer.get(), 
buffer_bytes);
                assert(in->get_position() <= in->get_tag_end_position());
 
                // Need to re-arrange ARGB into RGB.
                for (int j = 0; j < height; j++)
                {
-                   uint8_t*    image_in_row = buffer + j * pitch;
+                   uint8_t*    image_in_row = buffer.get() + j * pitch;
                    uint8_t*    image_out_row = image::scanline(image.get(), j);
                    for (int i = 0; i < width; i++)
                    {
@@ -529,7 +534,6 @@
                    }
                }
 
-               delete [] buffer;
            }
 
            if ( m->get_bitmap_character_def(character_id) )
@@ -558,22 +562,23 @@
                // 8-bit data, preceded by a palette.
 
                const int bytes_per_pixel = 1;
+               in->ensureBytes(1); // color table size
                int color_table_size = in->read_u8();
                color_table_size++;     // !! SWF stores one less than the 
actual size
 
                int pitch = (width * bytes_per_pixel + 3) & ~3;
 
                int buffer_bytes = color_table_size * 4 + pitch * height;
-               uint8_t* buffer = new uint8_t[buffer_bytes];
+               boost::scoped_array<uint8_t> buffer ( new uint8_t[buffer_bytes] 
);
 
-               inflate_wrapper(in->get_underlying_stream(), buffer, 
buffer_bytes);
+               inflate_wrapper(in->get_underlying_stream(), buffer.get(), 
buffer_bytes);
                assert(in->get_position() <= in->get_tag_end_position());
 
-               uint8_t* color_table = buffer;
+               uint8_t* color_table = buffer.get();
 
                for (int j = 0; j < height; j++)
                {
-                   uint8_t*    image_in_row = buffer + color_table_size * 4 + 
j * pitch;
+                   uint8_t*    image_in_row = buffer.get() + color_table_size 
* 4 + j * pitch;
                    uint8_t*    image_out_row = image::scanline(image.get(), j);
                    for (int i = 0; i < width; i++)
                    {
@@ -585,7 +590,6 @@
                    }
                }
 
-               delete [] buffer;
            }
            else if (bitmap_format == 4)
            {
@@ -594,14 +598,14 @@
                int pitch = (width * bytes_per_pixel + 3) & ~3;
 
                int buffer_bytes = pitch * height;
-               uint8_t* buffer = new uint8_t[buffer_bytes];
+               boost::scoped_array<uint8_t> buffer ( new uint8_t[buffer_bytes] 
);
 
-               inflate_wrapper(in->get_underlying_stream(), buffer, 
buffer_bytes);
+               inflate_wrapper(in->get_underlying_stream(), buffer.get(), 
buffer_bytes);
                assert(in->get_position() <= in->get_tag_end_position());
 
                for (int j = 0; j < height; j++)
                {
-                   uint8_t*    image_in_row = buffer + j * pitch;
+                   uint8_t*    image_in_row = buffer.get() + j * pitch;
                    uint8_t*    image_out_row = image::scanline(image.get(), j);
                    for (int i = 0; i < width; i++)
                    {
@@ -615,7 +619,6 @@
                    }
                }
 
-               delete [] buffer;
            }
            else if (bitmap_format == 5)
            {
@@ -643,7 +646,6 @@
            }
 
            bitmap_character_def* ch = new bitmap_character_def(image);
-//         delete image;
 
            // add image to movie, under character id.
            m->add_bitmap_character_def(character_id, ch);
@@ -1314,7 +1316,7 @@
        bool sample_16bit, bool stereo, unsigned int &sample_count,
        unsigned char* &data, unsigned &data_bytes)
 {
-    assert(data_bytes < sample_count);
+    assert(sample_count < data_bytes);
 
     // Make sure that an unassigned pointer cannot get through
     data = NULL;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]