[m-dev.] trivial diff: fix memory bug in IO exception handling
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Sep 15 19:11:25 AEDT 2000
Estimated hours taken: 0.25
library/io.m:
Fix a bug: it was calling MR_make_aligned_string()
when it should have been calling MR_make_aligned_string_copy().
This meant it might throw an exception object containing
the address of a local variable.
cvs diff -u12 library/io.m
Index: library/io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.202
diff -u -d -u -1 -2 -r1.202 io.m
--- library/io.m 2000/09/11 04:28:13 1.202
+++ library/io.m 2000/09/15 08:06:23
@@ -2784,25 +2784,25 @@
char message[5000];
ConstString message_as_mercury_string;
/* the `mf' parameter is currently not used */
/* format the error message using vsprintf() */
va_start(args, format);
vsprintf(message, format, args);
va_end(args);
/* copy the error message to a Mercury string */
restore_registers(); /* for MR_hp */
- MR_make_aligned_string(message_as_mercury_string, message);
+ MR_make_aligned_string_copy(message_as_mercury_string, message);
save_registers(); /* for MR_hp */
/* call some Mercury code to throw the exception */
ML_throw_io_error((String) message_as_mercury_string);
}
").
:- pragma c_code("
void
mercury_output_error(MercuryFile *mf)
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list