[gnu.ghostscript.bug] Memory leak - imagemask

ghost@aladdin.com (L. Peter Deutsch) (08/16/89)

A bug has been discovered in the image and imagemask operators that
causes at least 516 bytes of memory to be permanently lost each time
one of these operators is invoked.  This causes major problems for
dvi2ps output, which uses bitmap (image) fonts.

The bug will, of course, be fixed in the imminent 1.4 release.
Meanwhile, here is the patch to the image_continue procedure in
zpaint.c:

/* Continuation procedure.  Hand the string to the enumerator. */
private int
image_continue(register ref *op)
{	gs_image_enum *penum = (gs_image_enum *)esp->value.bytes;
	int code;
	if ( r_type(op) != t_string )
	   {	/* Procedure didn't return a string.  Quit. */
		esp -= inumpush;
		alloc_free((char *)penum, gs_image_enum_sizeof,
			   "image_continue(quit)");
		return e_typecheck;
	   }
	code = gs_image_next(penum, op->value.bytes, op->size);
	if ( op->size == 0 || code > 0 )	/* stop now */
	   {	esp -= inumpush;
		alloc_free((char *)penum, gs_image_enum_sizeof,
			   "image_continue(finished)");
	   }
<<< rest of procedure is unchanged >>>

This bug has been present in every version of Ghostscript, but
apparently no one was running dvi2ps output through Ghostscript until
recently.

L. Peter Deutsch			ghost@aladdin.com
Aladdin Enterprises			...{uunet,parcplace}!aladdin!ghost
P. O. box 60264, Palo Alto, CA 94306