Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2003:
[Freeciv-Dev] (PR#4025) gui-xaw compile error
Home

[Freeciv-Dev] (PR#4025) gui-xaw compile error

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: per@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#4025) gui-xaw compile error
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 18 Apr 2003 12:38:35 -0700
Reply-to: rt@xxxxxxxxxxxxxx

[per - Fri Apr 18 11:06:46 2003]:

> gcc -DHAVE_CONFIG_H -I. -I. -I../.. -I. -I./.. -I./../include
> -I../../common -I../../intl  -I/usr/X11R6/include    -g -O3 -Wall -Werror
> -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wstrict-prototypes
> -Wnested-externs -Wmissing-declarations -c `test -f wldlg.c || echo
> './'`wldlg.c
> cc1: warnings being treated as errors
> graphics.c: In function `load_gfxfile':
> graphics.c:344: warning: variable `ptransarray' might be clobbered by
> `longjmp' or `vfork'
> make[4]: *** [graphics.o] Error 1
> make[4]: *** Waiting for unfinished jobs....
> make[4]: Leaving directory `/home/perrin/freeciv-dipl/client/gui-xaw'
> 
> No idea what this means.

libpng uses setjmp/longjmp for its error handling.  In this particular
case I believe longjmp is called by png_read_image, if there's an error,
causing execution to miraculously jump to the point where setjmp was
called (up above).  At this point I guess it's undefined (or
implementation-defined) what value pcolorarray has, since it was
initialized to NULL but then (possibly) malloc'd later.  Of course, I
doubt it matters much since the program immediately exits...but in the
future it should be possible to have non-fatal error-handling here, to
make using different tilesets easier.

A proper fix might be to get libpng changed to not use longjmp, or even
to get posix changed to get longjmp removed entirely.  As it is, I hope
the attached patch will work, potentially allowing pcolorarray to be
freed after the longjmp call.  I can't tell, since I don't get this
warning (gcc 3.2.3 20030415).

jason

Index: client/gui-xaw/graphics.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/graphics.c,v
retrieving revision 1.46
diff -u -r1.46 graphics.c
--- client/gui-xaw/graphics.c   2002/12/17 22:41:04     1.46
+++ client/gui-xaw/graphics.c   2003/04/18 19:29:43
@@ -341,7 +341,7 @@
   png_bytep buf, pb;
   png_uint_32 stride;
   unsigned long *pcolorarray;
-  bool *ptransarray = NULL;
+  bool *ptransarray;
   struct Sprite *mysprite;
   XImage *xi;
   int has_mask;
@@ -414,6 +414,8 @@
     for (i = 0; i < ntrans; i++) {
       ptransarray[trans[i]] = TRUE;
     }
+  } else {
+    ptransarray = NULL;
   }
 
   png_read_update_info(pngp, infop);

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