commit 4e9dfdaae6ff296b363b7f91de998115599fd1c5
parent 6f3f633f13e5d3bb26a34f2ae89a0f59452ac515
Author: Drew DeVault <sir@cmpwn.com>
Date: Wed, 10 Mar 2021 12:45:38 -0500
hare::module: fix invalid frees
Diffstat:
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/hare/module/context.ha b/hare/module/context.ha
@@ -30,7 +30,7 @@ export fn context_init(tags: []tag) context = {
paths: []str = match (os::getenv("HAREPATH")) {
void => {
let path: []str = alloc([
- DEFAULT_HAREPATH,
+ strings::dup(DEFAULT_HAREPATH),
dirs::data("hare"),
]);
path;
@@ -38,18 +38,17 @@ export fn context_init(tags: []tag) context = {
s: str => {
let sl = strings::split(s, ":");
let path: []str = alloc([], len(sl) + 1);
- let i = 0z;
- for (i < len(sl); i += 1) {
- append(path, sl[i]);
+ for (let i = 0z; i < len(sl); i += 1) {
+ append(path, strings::dup(sl[i]));
};
- append(path, ".");
+ append(path, strings::dup("."));
free(sl);
path;
},
},
cache: str = match (os::getenv("HARECACHE")) {
void => dirs::cache("hare"),
- s: str => s,
+ s: str => strings::dup(s),
},
...
};