Thanks to Sven Neumann a version of the XPI based on libmng-1.0.8-alpha is now available. This should fix crashes on some MNG files.
MNG for Linux, GCC 3
Additionally, a version using libmng 1.0.8a for Mozilla 1.7 on OS/2 and eComStation is available, thanks to Peter Weilbacher: MNG for OS/2
components/ subdirectory of your mozilla
installation directory for installing the XPI. This may mean that you
must be root when installing it. After installing the mng support, it
will be available for all users using this version of Mozilla. You have basically two possibilities: I have built the XPI using Mozilla 1.4, which still includes MNG, replacing modules/libimg/mng/ with the new libmng sources.
The alternative is to apply the patch from http://bugzilla.mozilla.org/show_bug.cgi?id=18574#c408 (probably also replacing the libmng code as mentioned above).
After that, unzip the .xpi file (it's a renamed .zip file), replace libimgmng.so with the one in your newly built mozilla (in the dist/bin/components directory). For compatibility with nightly builds, use GCC 3 as the compiler. Then, rezip it. (Updating the version number in install.js would probably also be a good idea)
I am not sure if the patch supports building using a systemwide installed libmng, probably it does, you'd want to build with --with-system-mng probably. Either way, you'll want --disable-debug --enable-optimize.
Please refer to http://www.mozilla.org/build/ for general instructions on building Mozilla.