[gs-cvs] rev 9576 - trunk/gs/psi
alexcher at ghostscript.com
alexcher at ghostscript.com
Thu Mar 19 14:19:32 PDT 2009
Author: alexcher
Date: 2009-03-19 14:19:31 -0700 (Thu, 19 Mar 2009)
New Revision: 9576
Modified:
trunk/gs/psi/zfile.c
Log:
Allocate a file name string returned by .tempfile independently of the
file object. Don't free the file name string when the file is closed.
Fix a Valgrind warning and potential SEGV.
DIFFERENCES:
None.
Modified: trunk/gs/psi/zfile.c
===================================================================
--- trunk/gs/psi/zfile.c 2009-03-19 17:01:34 UTC (rev 9575)
+++ trunk/gs/psi/zfile.c 2009-03-19 21:19:31 UTC (rev 9576)
@@ -679,7 +679,7 @@
uint fnlen;
FILE *sfile;
stream *s;
- byte *buf;
+ byte *buf, *sbody;
if (code < 0)
return code;
@@ -720,15 +720,21 @@
return_error(e_invalidfileaccess);
}
fnlen = strlen(fname);
+ sbody = ialloc_string(fnlen, ".tempfile(fname)");
+ if (sbody == 0) {
+ gs_free_object(imemory, buf, "ztempfile(buffer)");
+ return_error(e_VMerror);
+ }
+ memcpy(sbody, fname, fnlen);
file_init_stream(s, sfile, fmode, buf, file_default_buffer_size);
code = ssetfilename(s, (const unsigned char*) fname, fnlen);
if (code < 0) {
sclose(s);
iodev_default->procs.delete_file(iodev_default, fname);
+ ifree_string(sbody, fnlen, ".tempfile(fname)");
return_error(e_VMerror);
}
- make_const_string(op - 1, a_readonly | icurrent_space, fnlen,
- s->file_name.data);
+ make_string(op - 1, a_readonly | icurrent_space, fnlen, sbody);
make_stream_file(op, s, fmode);
return code;
}
More information about the gs-cvs
mailing list