diff --git a/libc3/env.c b/libc3/env.c
index 4e30744..0fb1589 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -250,8 +250,11 @@ s_module * env_module_load (s_env *env, s_module *module,
buf_write_s8(&env->out, '\n');
buf_flush(&env->out);
*/
- if (facts_load_file(facts, path.ptr.ps8) < 0)
+ if (facts_load_file(facts, path.ptr.ps8) < 0) {
+ str_clean(&path);
return 0;
+ }
+ str_clean(&path);
return module;
}
diff --git a/libc3/module.c b/libc3/module.c
index c71c3fa..1850103 100644
--- a/libc3/module.c
+++ b/libc3/module.c
@@ -34,7 +34,7 @@ s_str * module_name_path (const s_str *prefix, const s_sym *name,
assert(name);
buf_init_str(&in, &name->str);
out_size = module_name_path_size(prefix, name);
- buf_init_alloc(&out, out_size + 1);
+ buf_init_alloc(&out, out_size);
if ((r = buf_write_str(&out, prefix)) < 0)
goto error;
if ((r = buf_write_s8(&out, '/')) < 0)
@@ -55,8 +55,6 @@ s_str * module_name_path (const s_str *prefix, const s_sym *name,
}
if ((r = buf_write_1(&out, FACTS_EXT)) < 0)
goto error;
- if ((r = buf_write_s8(&out, 0)) < 0)
- goto error;
buf_clean(&in);
return buf_to_str(&out, dest);
error: