libpng bug fixed - yipee


Subject: libpng bug fixed - yipee
From: sam th (sam@bur-jud-118-039.rh.uchicago.edu)
Date: Thu Apr 13 2000 - 08:19:36 CDT


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I love the smell of pointers in the morning. :-)
Self-congratulation aside (although it is nice to fix code you don't
understand), the fix for this was really trivial. all you have to do is
add the line

        png_ptr->io_ptr = &myBB;

at line 82 (right before the comment) in src/af/util/xp/ut_png.cpp
I would appreciate someone else testing this before I submit the patch.

Now, for anyone who cares, here is what was going wrong:

In ut_png.cpp we tell libpng to call _png_read(), one of our functions, to
get input. However, _png_read() contains the following lines

        struct _bb* p = (struct _bb*) png_ptr->io_ptr;
        const UT_Byte* pBytes = p->pBB->getPointer(0);

Sadly, when we got to _png_read() png_ptr->io_ptr was a null pointer.
Now, this was not the intende behavior. However, we inialize it as null,
and never change it ourselves. The change is supposed to happen when we
make the following call
        
        png_set_read_fn(png_ptr, (void *)&myBB, _png_read);

Now, the first line of png_set_read_fn() is, roughly,
        
        first_arg->io_ptr = second_arg;

In other words, it preforms this assignment

        png_ptr->io_ptr = &myBB;

However, it wasn't happening. I still do not know why. So, I did the
assignment manually (see the first line of code in this message). Then it
worked. Voila.

By now, no one is reading this, but it was fun anyway.

           
                                     sam th
                                     sytobinh@uchicago.edu
                                http://bur-jud-118-039.rh.uchicago.edu
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE49clqt+kM0Mq9M/wRAhRVAKDDVSYIK12GhLjvn6b/S9/ilx5zbACgiQkL
4jr5eXiV6zTIT9Vf0zeJjGI=
=0aUB
-----END PGP SIGNATURE-----



This archive was generated by hypermail 2b25 : Thu Apr 13 2000 - 08:19:40 CDT