From 3dfdbd35a12fb256598eece04422d34b5dee9edc Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 8 May 2023 22:41:36 -0400 Subject: [PATCH] comp/c: fix arena selection bug for struct CDecl This caused memory corruption bugs because struct fields would end up in the temporary arena. --- fs/comp/c/fgen.fs | 2 +- fs/comp/c/type.fs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/comp/c/fgen.fs b/fs/comp/c/fgen.fs index 49da7073..87e4c4b0 100644 --- a/fs/comp/c/fgen.fs +++ b/fs/comp/c/fgen.fs @@ -173,7 +173,7 @@ current ' parseStatement realias \ '{' is already parsed : parseFunctionBody ( cdecl -- ) - 0 to _locvars 0 to _initcode to _curfunc _litarena :reserve ( ) + 0 to _locvars 0 to _initcode to _curfunc ( ) STORAGE_RS to@! curstorage >r begin nextt dup parseType while ( tok type ) nip parseDeclLine repeat ( tok ) to nexttputback r> to curstorage diff --git a/fs/comp/c/type.fs b/fs/comp/c/type.fs index 5a8490b5..2ce0cc67 100644 --- a/fs/comp/c/type.fs +++ b/fs/comp/c/type.fs @@ -38,7 +38,7 @@ $b const TYPE_UINT STORAGE_MEM value curstorage 0 value curstatic \ is current definition "static"? -: _arena curstorage STORAGE_MEM <> curstatic or if _tarena else _parena then ; +: _arena curstorage STORAGE_MEM < curstatic or if _tarena else _parena then ; 8 stringlist typenames "void" "char" "short" "int" "" "" "" "" -- 2.38.5