[m-dev.] diff: mdb memory management bug fix
Zoltan Somogyi
zs at cs.mu.OZ.AU
Fri Aug 25 19:58:31 AEST 2000
trace/mercury_trace_spy.c:
When storing filenames in tables, make copies of the string first,
because it comes from a input buffer that may be clobbered later.
Free the copied string when its lifetime is over.
Zoltan.
cvs diff: Diffing .
Index: mercury_trace_spy.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_spy.c,v
retrieving revision 1.9
diff -u -r1.9 mercury_trace_spy.c
--- mercury_trace_spy.c 2000/08/03 06:19:30 1.9
+++ mercury_trace_spy.c 2000/08/07 03:47:59
@@ -342,6 +342,13 @@
int point_slot;
int old_size, new_size;
+ /*
+ ** The original filename string may have come from a buffer
+ ** or other volatile storage.
+ */
+
+ filename = MR_copy_string(filename);
+
point_slot = MR_spy_point_next;
old_size = MR_spied_label_next;
@@ -420,6 +427,9 @@
point->spy_exists = FALSE;
if (point->spy_when == MR_SPY_LINENO) {
+ /* Release the storage acquired by MR_copy_string. */
+ MR_free((void *) point->spy_filename);
+
/*
** Remove the spy point from the spied label table list.
*/
--------------------------------------------------------------------------
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