From e251200a2f9b26993a7ef12e7ed8b3f2247beaaf Mon Sep 17 00:00:00 2001 From: dimgigov Date: Sun, 31 May 2026 20:49:54 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20null-safe=20bux=5Fstrcmp/bux=5Fstrncmp/b?= =?UTF-8?q?ux=5Fstrcpy,=20init=20alloca=20typeName=20=E2=80=94=20project?= =?UTF-8?q?=20build=20no=20longer=20crashes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _selfhost/src/hir_lower.bux | 1 + src_bux/hir_lower.bux | 1 + stdlib/runtime.c | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/_selfhost/src/hir_lower.bux b/_selfhost/src/hir_lower.bux index 01ec1c9..71a9533 100644 --- a/_selfhost/src/hir_lower.bux +++ b/_selfhost/src/hir_lower.bux @@ -170,6 +170,7 @@ func Lcx_LowerStmt(ctx: *LowerCtx, stmt: *Stmt) -> *HirNode { alloca.column = col; alloca.strValue = stmt.strValue; // Set type from the declared type expression + alloca.typeName = ""; if stmt.refStmtType != null as *TypeExpr { alloca.intValue = stmt.refStmtType.kind; alloca.typeName = stmt.refStmtType.typeName; diff --git a/src_bux/hir_lower.bux b/src_bux/hir_lower.bux index 01ec1c9..71a9533 100644 --- a/src_bux/hir_lower.bux +++ b/src_bux/hir_lower.bux @@ -170,6 +170,7 @@ func Lcx_LowerStmt(ctx: *LowerCtx, stmt: *Stmt) -> *HirNode { alloca.column = col; alloca.strValue = stmt.strValue; // Set type from the declared type expression + alloca.typeName = ""; if stmt.refStmtType != null as *TypeExpr { alloca.intValue = stmt.refStmtType.kind; alloca.typeName = stmt.refStmtType.typeName; diff --git a/stdlib/runtime.c b/stdlib/runtime.c index e4a6cb7..f3bc044 100644 --- a/stdlib/runtime.c +++ b/stdlib/runtime.c @@ -144,14 +144,21 @@ unsigned int bux_strlen(const char* s) { } int bux_strcmp(const char* a, const char* b) { + if (a == b) return 0; + if (!a) return -1; + if (!b) return 1; return strcmp(a, b); } int bux_strncmp(const char* a, const char* b, unsigned int n) { + if (a == b) return 0; + if (!a) return -1; + if (!b) return 1; return strncmp(a, b, (size_t)n); } char* bux_strcpy(char* dest, const char* src) { + if (!dest || !src) return dest; return strcpy(dest, src); }