about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNakidai <nakidai@disroot.org>2025-03-31 03:19:22 +0300
committerNakidai <nakidai@disroot.org>2025-03-31 03:19:22 +0300
commit00dbb67ff654c4d76ef1c3177927bc8eebff6f85 (patch)
treeed43ec7967e72ea99b823904da1283cbb8fe4501
parent2efe02624ba94618da722acd4e6ad49d9610afd8 (diff)
download3cl-00dbb67ff654c4d76ef1c3177927bc8eebff6f85.tar.gz
3cl-00dbb67ff654c4d76ef1c3177927bc8eebff6f85.zip
Fix infinite loop bug
When *infinite* loop is called, there's an UB when accessing *p
that points to n that was valid only inside the if block
-rw-r--r--executor.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/executor.c b/executor.c
index 0542a9c..5806981 100644
--- a/executor.c
+++ b/executor.c
@@ -251,10 +251,9 @@ enum cccl_ExecutorStatus cccl_execute(struct cccl_Node *code, struct cccl_Variab
     } break;
     case cccl_Node_INFINITE:
     {
-        short *p;
+        short n = 1, *p;
         if (code->value == '_')
         {
-            short n = 1;
             p = &n;
         } else
         {