Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 03 Jan 2002 22:28:25 UTC
From:      Oddmund Johannesen <oddjohan@c2i.net>
To:        shige@freebsd.org
Cc:        ports@freebsd.org
Subject:   FreeBSD Port: xv-3.10a, postscript bug
Message-ID:  <20020103222826@mail>

next in thread | raw e-mail | index | archive | help
Greetings,

During the last couple of months I have been plagued by a nasty bug
when writing PostScript files.  On all platforms I normally use I
always get a coredump when writing a .ps file after doing a gamma
correction.  Actually, on my FreeBSD system the bug apparently
translates to a memory leak, as a call to free(3) detects an invalid
pointer.

Today I decided to find the bug, and it turned out to be very simple:
It's the inpix pointer below that gets freed after having been updated
from the time of being malloc-ed.

The following patch will fix the bug.

-- Oddmund Johannesen.


--- xvps.c.orig	Thu Dec 22 23:34:42 1994
+++ xvps.c	Thu Jan  3 13:05:43 2002
@@ -891,7 +891,7 @@
   int   i, j, q, err, rpix, gpix, bpix, nc, ptype;
   int   iw, ih, ox, oy, slen, lwidth, bits, colorps, w, h, pfree;
   double iwf, ihf;
-  byte *inpix, *rmap, *gmap, *bmap;
+  byte *inpix, *rmap, *gmap, *bmap, *thepic;
 
   slen = bits = colorps = 0;
 
@@ -902,7 +902,7 @@
   WaitCursor();
   
   inpix = GenSavePic(&ptype, &w, &h, &pfree, &nc, &rmap, &gmap, &bmap);
-
+  thepic = inpix;  /* Keep for removal. */
     
   /* printed image will have size iw,ih (in picas) */
   iw = (int) (sz_inx * 72.0 + 0.5);
@@ -1123,7 +1123,7 @@
   fprintf(fp,"origstate restore\n\n");
   fprintf(fp,"%%%%Trailer\n");
 
-  if (pfree) free(inpix);
+  if (pfree) free(thepic);
 
   if (CloseOutFile(fp, filename, (err==EOF)) == 0) {
     DirBox(0);


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020103222826>