[hackers] [sbase] bc: Force a unwind string in every function || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sun, 18 Jan 2026 17:52:49 +0100 (CET)

commit c00921a3a3eabb3f908fc22eff9189c756274742
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.net>
AuthorDate: Sun Jan 18 11:26:26 2026 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.net>
CommitDate: Sun Jan 18 17:52:37 2026 +0100

    bc: Force a unwind string in every function
    
    The code in funcode() assumes that the string unwind has a
    value but it didn't happen in the case of a function without
    parameters or local variables.

diff --git a/bc.y b/bc.y
index b301427..ce22abd 100644
--- a/bc.y
+++ b/bc.y
_AT_@ -356,6 +356,7 @@ macro(int op)
                 inhome = 1;
                 break;
         case DEF:
+ unwind = estrdup("");
                 inhome = 0;
                 d->id = funid(yytext);
                 d->flowid = macros[0].flowid;
_AT_@ -391,8 +392,7 @@ decl(int type, char *list, char *id)
         i2 = estrdup(id);
         free(id);
 
- if (!unwind)
- unwind = estrdup("");
+ unwind = estrdup("");
         if (!list)
                 list = estrdup("");
 
diff --git a/tests/0046-bc.sh b/tests/0046-bc.sh
new file mode 100755
index 0000000..5a98a6d
--- /dev/null
+++ b/tests/0046-bc.sh
_AT_@ -0,0 +1,19 @@
+#!/bin/sh
+
+tmp=$$.tmp
+
+trap 'rm -f $tmp' EXIT
+trap 'exit $?' HUP INT TERM
+
+cat <<'EOF' > $tmp
+0
+0
+EOF
+
+$EXEC ../bc -p ../dc <<'EOF' | diff -u - $tmp
+define a() {
+0
+}
+
+a()
+EOF
Received on Sun Jan 18 2026 - 17:52:49 CET

This archive was generated by hypermail 2.3.0 : Sun Jan 18 2026 - 18:00:35 CET