diff -ur jasper-1.700.2/src/libjasper/base/jas_stream.c jasper-1.700.2-local/src/libjasper/base/jas_stream.c
--- jasper-1.700.2/src/libjasper/base/jas_stream.c	Sun Feb  9 10:27:29 2003
+++ jasper-1.700.2-local/src/libjasper/base/jas_stream.c	Tue Jun 17 23:06:57 2003
@@ -408,11 +408,11 @@
 	}
 	obj->fd = -1;
 	obj->flags = 0;
-	obj->pathname[0] = '\0';
+	strncpy(obj->pathname, "jasXXXXXX", sizeof(obj->pathname));
 	stream->obj_ = obj;
 
 	/* Choose a file name. */
-	tmpnam(obj->pathname);
+	mkstemp(obj->pathname);
 
 	/* Open the underlying file. */
 	if ((obj->fd = open(obj->pathname, O_CREAT | O_EXCL | O_RDWR | O_TRUNC | O_BINARY,
diff -ur jasper-1.700.2/src/libjasper/jpg/jpg_enc.c jasper-1.700.2-local/src/libjasper/jpg/jpg_enc.c
--- jasper-1.700.2/src/libjasper/jpg/jpg_enc.c	Sun Feb  9 11:38:25 2003
+++ jasper-1.700.2-local/src/libjasper/jpg/jpg_enc.c	Tue Jun 17 22:46:16 2003
@@ -380,6 +380,7 @@
 	rewind(output_file);
 	jpg_copyfiletostream(out, output_file);
 	fclose(output_file);
+	jas_matrix_destroy(src_mgr->data);
 	output_file = 0;
 
 	return 0;
