From b8dbbe9e433930206eb8bc974c1dce03ba14d300 Mon Sep 17 00:00:00 2001 From: Amyr Ahmady Date: Mon, 7 Oct 2019 11:12:59 +0330 Subject: [PATCH] fix "#pragma option" crash when character count is over 31 For some reason `i` will be `32` after our for loop so an OOB happens when code tries to assign `'\0'` to `name[32]` since `name` size is 32. Doing a `-1` to `i` fixed this issue and now throws `error 038: extra characters on line` when character count is over 31. --- source/compiler/sc2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/compiler/sc2.c b/source/compiler/sc2.c index 25c0d9d..ac00a18 100644 --- a/source/compiler/sc2.c +++ b/source/compiler/sc2.c @@ -1344,7 +1344,7 @@ static int command(void) lptr++; for (i=0; i' '; i++,lptr++) name[i]=*lptr; - name[i]='\0'; + name[i-1]='\0'; parsesingleoption(name); } else { error(207); /* unknown #pragma */