From 1f884b0f99cb218cfc97c92636bc0a63482c221e Mon Sep 17 00:00:00 2001 From: Carlo Bramini <30959007+carlo-bramini@users.noreply.github.com> Date: Tue, 12 May 2026 11:16:14 +0200 Subject: [PATCH] Fix uninitialized bug into cstringlength I made a project with VS 2022 and I tried to compile the BASIC interpreter, but it refused to build basic.c because there is a bug into cstringlength(). Actually the variable "a" is not initialized to zero and Microsoft C compiler signals this as an error. Attached patch fixes this error in all versions of the interpreter. --- Basic2/MSDOS/basic.c | 2 +- Basic2/Posix/basic.c | 2 +- Basic2/RaspPi/basic.c | 2 +- Basic2/Windows/basic.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Basic2/MSDOS/basic.c b/Basic2/MSDOS/basic.c index 9cb387f..e4fff7e 100644 --- a/Basic2/MSDOS/basic.c +++ b/Basic2/MSDOS/basic.c @@ -1608,7 +1608,7 @@ void storecstring(address_t ax, address_t s, char* b) { /* length of a c string up to a limit l */ address_t cstringlength(char* c, address_t l) { - address_t a; + address_t a = 0; while(a < l && c[a] != 0) a++; return a; diff --git a/Basic2/Posix/basic.c b/Basic2/Posix/basic.c index f17dd20..81890b2 100755 --- a/Basic2/Posix/basic.c +++ b/Basic2/Posix/basic.c @@ -1836,7 +1836,7 @@ void storecstring(address_t ax, address_t s, char* b) { /* length of a c string up to a limit l */ address_t cstringlength(char* c, address_t l) { - address_t a; + address_t a = 0; while (a < l && c[a] != 0) a++; return a; diff --git a/Basic2/RaspPi/basic.c b/Basic2/RaspPi/basic.c index 35b352e..6c8f6cb 100755 --- a/Basic2/RaspPi/basic.c +++ b/Basic2/RaspPi/basic.c @@ -1657,7 +1657,7 @@ void storecstring(address_t ax, address_t s, char* b) { /* length of a c string up to a limit l */ address_t cstringlength(char* c, address_t l) { - address_t a; + address_t a = 0; while(a < l && c[a] != 0) a++; return a; diff --git a/Basic2/Windows/basic.c b/Basic2/Windows/basic.c index 35b352e..6c8f6cb 100755 --- a/Basic2/Windows/basic.c +++ b/Basic2/Windows/basic.c @@ -1657,7 +1657,7 @@ void storecstring(address_t ax, address_t s, char* b) { /* length of a c string up to a limit l */ address_t cstringlength(char* c, address_t l) { - address_t a; + address_t a = 0; while(a < l && c[a] != 0) a++; return a;