shithub: MicroHs

Download patch

ref: b6907a66fed4202b37293c18b7802ed01c239fad
parent: 14d95e9e4dd27f8ff085c3eecb977cd5a853f669
author: Lennart Augustsson <lennart@augustsson.net>
date: Sat Aug 31 13:30:15 EDT 2024

Avoid empty strings in append

--- a/src/runtime/eval.c
+++ b/src/runtime/eval.c
@@ -2582,6 +2582,10 @@
 struct bytestring
 bsappend(struct bytestring p, struct bytestring q)
 {
+  if (p.size == 0)
+    return q;
+  if (q.size == 0)
+    return p;
   struct bytestring r;
   r.size = p.size + q.size;
   r.string = MALLOC(r.size);
--