~vdupras/duskos

3dfdbd35a12fb256598eece04422d34b5dee9edc — Virgil Dupras 1 year, 4 months ago 60edd42
comp/c: fix arena selection bug for struct CDecl

This caused memory corruption bugs because struct fields would end up in the
temporary arena.
2 files changed, 2 insertions(+), 2 deletions(-)

M fs/comp/c/fgen.fs
M fs/comp/c/type.fs
M fs/comp/c/fgen.fs => fs/comp/c/fgen.fs +1 -1
@@ 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

M fs/comp/c/type.fs => fs/comp/c/type.fs +1 -1
@@ 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" "" "" "" ""