# HG changeset patch # User Eli Zaretskii # Date 1293799086 -7200 # Node ID 704900942a8edf2f2b0d87fbd10b666af71da5ac # Parent 9336a48575076fb2df93e258f7d2aef770b149e6 Fix bug #7716 with PNG image support libraries on Windows. src/image.c : New variable. (syms_of_image): Intern and staticpro it. Set its value to the version of PNG library we were compiled with. (my_png_error, png_load): Avoid GCC warnings about direct access to png_ptr->jmpbuf. lisp/term/w32-win.el (image-library-alist): Set up correctly for libpng versions both before and after 1.4.0. admin/nt/README.W32: Update the information about PNG support libraries. nt/INSTALL: Update the information about PNG support libraries. diff -r 9336a4857507 -r 704900942a8e admin/ChangeLog --- a/admin/ChangeLog Thu Dec 30 20:39:41 2010 +0800 +++ b/admin/ChangeLog Fri Dec 31 14:38:06 2010 +0200 @@ -1,3 +1,8 @@ +2010-12-31 Eli Zaretskii + + * nt/README.W32: Update the information about PNG support libraries. + (Bug#7716) + 2010-05-07 Chong Yidong * Version 23.2 released. diff -r 9336a4857507 -r 704900942a8e admin/nt/README.W32 --- a/admin/nt/README.W32 Thu Dec 30 20:39:41 2010 +0800 +++ b/admin/nt/README.W32 Fri Dec 31 14:38:06 2010 +0200 @@ -119,14 +119,19 @@ libXpm library from X11R7.3. Emacs can also support some other image formats with appropriate - libraries. These libraries are all available as part of GTK, or from - gnuwin32.sourceforge.net. Emacs will find them if the directory they - are installed in is on the PATH. + libraries. These libraries are all available as part of GTK + download for Windows (http://www.gtk.org/download-windows.html), or + from the GnuWin32 project. Emacs will find them if the directory + they are installed in is on the PATH. - PNG: requires the PNG reference library 1.2 or later, which will - be named libpng13d.dll, libpng13.dll, libpng12d.dll, libpng12.dll - or libpng.dll. LibPNG requires zlib, which should come from the same - source as you got libpng. + PNG: requires the PNG reference library 1.4 or later, which will + be named libpng14.dll or libpng14-14.dll. LibPNG requires zlib, + which should come from the same source as you got libpng. + Starting with Emacs 23.3, the precompiled Emacs binaries are + built with libpng 1.4.x and later, and are incompatible with + earlier versions of libpng DLLs. So if you have libpng 1.2.x, + the PNG support will not work, and you will have to download + newer versions. JPEG: requires the Independant JPEG Group's libjpeg 6b or later, which will be called jpeg62.dll, libjpeg.dll, jpeg-62.dll or jpeg.dll. @@ -137,6 +142,9 @@ GIF: requires libungif or giflib 4.1 or later, which will be called giflib4.dll, libungif4.dll or libungif.dll. + If you have image support DLLs under different names, customize the + value of `image-library-alist'. + In addition, Emacs can be compiled to support SVG. This precompiled distribution has not been compiled that way, since the SVG library or one or more of its extensive dependencies appear to be diff -r 9336a4857507 -r 704900942a8e lisp/ChangeLog --- a/lisp/ChangeLog Thu Dec 30 20:39:41 2010 +0800 +++ b/lisp/ChangeLog Fri Dec 31 14:38:06 2010 +0200 @@ -1,3 +1,8 @@ +2010-12-31 Eli Zaretskii + + * term/w32-win.el (image-library-alist): Set up correctly for + libpng versions both before and after 1.4.0. (Bug#7716) + 2010-12-25 Eli Zaretskii * time.el (display-time-mode): Mention display-time-interval in diff -r 9336a4857507 -r 704900942a8e lisp/term/w32-win.el --- a/lisp/term/w32-win.el Thu Dec 30 20:39:41 2010 +0800 +++ b/lisp/term/w32-win.el Fri Dec 31 14:38:06 2010 +0200 @@ -200,17 +200,25 @@ ;;; Set default known names for image libraries (setq image-library-alist - '((xpm "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll") - (png "libpng12d.dll" "libpng12.dll" "libpng.dll" - ;; these are libpng 1.2.8 from GTK+ - "libpng13d.dll" "libpng13.dll") - (jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll") - (tiff "libtiff3.dll" "libtiff.dll") - (gif "giflib4.dll" "libungif4.dll" "libungif.dll") - (svg "librsvg-2-2.dll") - (gdk-pixbuf "libgdk_pixbuf-2.0-0.dll") - (glib "libglib-2.0-0.dll") - (gobject "libgobject-2.0-0.dll"))) + (list + '(xpm "libxpm.dll" "xpm4.dll" "libXpm-nox4.dll") + ;; Versions of libpng 1.4.x and later are incompatible with + ;; earlier versions. Set up the list of libraries according to + ;; the version we were compiled against. (If we were compiled + ;; without PNG support, libpng-version's value is -1.) + (if (>= libpng-version 10400) + ;; libpng14-14.dll is libpng 1.4.3 from GTK+ + '(png "libpng14-14.dll" "libpng14.dll") + '(png "libpng12d.dll" "libpng12.dll" "libpng3.dll" "libpng.dll" + ;; these are libpng 1.2.8 from GTK+ + "libpng13d.dll" "libpng13.dll")) + '(jpeg "jpeg62.dll" "libjpeg.dll" "jpeg-62.dll" "jpeg.dll") + '(tiff "libtiff3.dll" "libtiff.dll") + '(gif "giflib4.dll" "libungif4.dll" "libungif.dll") + '(svg "librsvg-2-2.dll") + '(gdk-pixbuf "libgdk_pixbuf-2.0-0.dll") + '(glib "libglib-2.0-0.dll") + '(gobject "libgobject-2.0-0.dll"))) ;;; multi-tty support (defvar w32-initialized nil diff -r 9336a4857507 -r 704900942a8e nt/ChangeLog --- a/nt/ChangeLog Thu Dec 30 20:39:41 2010 +0800 +++ b/nt/ChangeLog Fri Dec 31 14:38:06 2010 +0200 @@ -1,3 +1,8 @@ +2010-12-31 Eli Zaretskii + + * INSTALL: Update the information about PNG support libraries. + (Bug#7716) + 2010-08-02 Óscar Fuentes * cmdproxy.c (main): Use _snprintf instead of wsprintf, diff -r 9336a4857507 -r 704900942a8e nt/INSTALL --- a/nt/INSTALL Thu Dec 30 20:39:41 2010 +0800 +++ b/nt/INSTALL Fri Dec 31 14:38:06 2010 +0200 @@ -279,6 +279,23 @@ If GTK 2.0 is installed, addpm will arrange for its image libraries to be on the DLL search path for Emacs. + For PNG images, we recommend to use versions 1.4.x and later of + libpng, because previous versions had security issues. You can find + precompiled libraries and headers on the GTK download page for + Windows (http://www.gtk.org/download-windows.html). + + Versions 1.4.0 and later of libpng are binary incompatible with + earlier versions, so Emacs will only look for libpng libraries which + are compatible with the version it was compiled against. That + version is given by the value of the Lisp variable `libpng-version'; + e.g., 10403 means version 1.4.3. The variable `image-library-alist' + is automatically set to name only those DLL names that are known to + be compatible with the version given by `libpng-version'. If PNG + support does not work for you even though you have the support DLL + installed, check the name of the installed DLL against + `image-library-alist' and the value of `libpng-version', and + download compatible DLLs if needed. + * Experimental SVG support SVG support is currently experimental, and not built by default. diff -r 9336a4857507 -r 704900942a8e src/ChangeLog --- a/src/ChangeLog Thu Dec 30 20:39:41 2010 +0800 +++ b/src/ChangeLog Fri Dec 31 14:38:06 2010 +0200 @@ -1,3 +1,11 @@ +2010-12-31 Eli Zaretskii + + * image.c : New variable. + (syms_of_image): Intern and staticpro it. Set its value to the + version of PNG library we were compiled with. + (my_png_error, png_load): Avoid GCC warnings about direct access + to png_ptr->jmpbuf. (Bug#7716) + 2010-12-27 Stefan Monnier * .gdbinit (xgetptr): Fix the union+lsb case. diff -r 9336a4857507 -r 704900942a8e src/image.c --- a/src/image.c Thu Dec 30 20:39:41 2010 +0800 +++ b/src/image.c Fri Dec 31 14:38:06 2010 +0200 @@ -94,6 +94,11 @@ without modifying lots of files). */ extern void x_query_colors (struct frame *f, XColor *colors, int ncolors); extern void x_query_color (struct frame *f, XColor *color); + +/* Version of libpng that we were compiled with, or -1 if no PNG + support was compiled in. This is tested by w32-win.el to correctly + set up the alist used to search for PNG libraries. */ +Lisp_Object Qlibpng_version; #endif /* HAVE_NTGUI */ #ifdef HAVE_NS @@ -5652,8 +5657,15 @@ char *msg; { xassert (png_ptr != NULL); + /* Avoid compiler warning about deprecated direct access to + png_ptr's fields in libpng versions 1.4.x. */ image_error ("PNG error: %s", build_string (msg), Qnil); +#if PNG_LIBPNG_VER_MAJOR > 1 \ + || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 4) + longjmp (png_jmpbuf (png_ptr), 1); +#else longjmp (png_ptr->jmpbuf, 1); +#endif } @@ -5827,9 +5839,16 @@ return 0; } + /* Avoid compiler warning about deprecated direct access to + png_ptr's fields in libpng versions 1.4.x. */ +#if PNG_LIBPNG_VER_MAJOR > 1 \ + || (PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR >= 4) /* Set error jump-back. We come back here when the PNG library detects an error. */ + if (setjmp (png_jmpbuf (png_ptr))) +#else if (setjmp (png_ptr->jmpbuf)) +#endif { error: if (png_ptr) @@ -8453,6 +8472,16 @@ staticpro (&QCpt_height); #endif /* HAVE_GHOSTSCRIPT */ +#ifdef HAVE_NTGUI + Qlibpng_version = intern_c_string ("libpng-version"); + staticpro (&Qlibpng_version); +#if HAVE_PNG + SET_SYMBOL_VAL (XSYMBOL (Qlibpng_version), make_number (PNG_LIBPNG_VER)); +#else + SET_SYMBOL_VAL (XSYMBOL (Qlibpng_version), make_number (-1)); +#endif +#endif + #if defined (HAVE_XPM) || defined (HAVE_NS) Qxpm = intern_c_string ("xpm"); staticpro (&Qxpm);