aboutsummaryrefslogtreecommitdiff
path: root/src/build.c
diff options
context:
space:
mode:
authordacctal <donotcontactmevia@email.invalid>2026-07-18 08:40:27 +0000
committerdacctal <donotcontactmevia@email.invalid>2026-07-18 08:40:27 +0000
commit45b6947f49e47a5aff2e2a93a1cca2bc913d869c (patch)
tree20dabcac7f850932779fa43d866c3bfdb82c7b42 /src/build.c
parent2375b4bf64ac43866860b85ff7411093eebf3080 (diff)
fix segfault in get_pkgsrc() with invalid str_fmt args
Diffstat (limited to 'src/build.c')
-rw-r--r--src/build.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/build.c b/src/build.c
index 72b1e40..1974846 100644
--- a/src/build.c
+++ b/src/build.c
@@ -69,6 +69,7 @@ bool bldit(package_t *pkg) {
lua_getglobal(B, "dependencies");
if (!lua_istable(B, -1)) {
bldit_isnt_type("dependencies", "table");
+ lua_pop(B, 1);
} else {
lua_pushnil(B);
install_dependencies(B);
@@ -77,14 +78,14 @@ bool bldit(package_t *pkg) {
lua_getglobal(B, "targets");
if (!lua_istable(B, -1)) {
bldit_isnt_type("targets", "table");
- lua_pop(B, 3);
+ lua_pop(B, 1);
lua_close(B);
+ B = NULL;
+ bldit_loaded = false;
return false;
}
bool target_success = target_build(B, "bldit.lua", &pkg->target);
lua_pop(B, 1);
- // lua_pop(B, 2);
- // lua_close(B);
return target_success;
}
@@ -155,7 +156,10 @@ bool build_loop(package_t *pkg) {
bool build(package_t *pkg) {
char cwd[MAX_PATH_LEN];
- getcwd(cwd, MAX_PATH_LEN);
+ if (getcwd(cwd, sizeof(cwd)) == NULL) {
+ log_error("getcwd failed");
+ return false;
+ }
if (!str_equal_cstr(&pkg->src, cwd) && !pkg->is_local)
chdir(pkg->src.data);