shithub: MicroHs

Download patch

ref: 1f78fbb7c97323669861ee578aad752ce09870fa
parent: e56a720c2f5057a74a91f4443c8971077973fcb3
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Thu Jul 25 08:58:02 EDT 2024

Some sanitize stuff.

--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,9 @@
 	$(CCEVAL) generated/mhs.c -o bin/mhs
 	$(CC) $(CCWARNS) -g -Isrc/runtime src/runtime/eval-$(CONF).c $(CCLIBS) generated/mhs.c -o bin/mhsgdb
 
+sanitizemhs:	ghcgen targets.conf
+	$(CCEVAL) -fsanitize=undefined -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract generated/mhs.c -o bin/mhssane
+
 # Compile mhs from distribution, with C compiler
 bin/mhs:	src/runtime/*.c src/runtime/*.h targets.conf #generated/mhs.c
 	@mkdir -p bin
--- a/src/runtime/eval.c
+++ b/src/runtime/eval.c
@@ -1523,6 +1523,11 @@
   }
 }
 
+/* The memory allocated here is never freed.
+ * This could be fixed by using a forptr and a
+ * finalizer for read UTF-8 strings.
+ * Fix this if there is a lot of deserialization.
+ */
 struct ustring *
 parse_string(BFILE *f)
 {
--