[m-rev.] for review: Fix crash in mercury_close in non-gc C grades.

Peter Wang novalazy at gmail.com
Wed Aug 21 17:17:18 AEST 2019


library/io.m:
    In mercury_open(), allocate a MercuryFile with MR_GC_NEW_ATTRIB
    instead of MR_incr_hp_type_msg to match the use of MR_GC_free
    in mercury_close() to free that allocation.

diff --git a/library/io.m b/library/io.m
index 64663e5c1..fbbb63aac 100644
--- a/library/io.m
+++ b/library/io.m
@@ -7957,7 +7957,7 @@ mercury_open(const char *filename, const char *openmode,
     }
 #endif
 
-    MR_incr_hp_type_msg(mf, MercuryFile, alloc_id, ""MercuryFile"");
+    mf = MR_GC_NEW_ATTRIB(MercuryFile, alloc_id);
     MR_mercuryfile_init(f, 1, mf);
     return mf;
 }
-- 
2.22.1



More information about the reviews mailing list