From c75c4423b0608053805e460321310bc5a254817b Mon Sep 17 00:00:00 2001 From: Matt Craighead Date: Mon, 31 Oct 2011 00:31:35 -0700 Subject: [PATCH] load() needs to check for undefined variables --- backend.cpp | 5 ++++- transform.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/backend.cpp b/backend.cpp index bdc8630..d6d9dfb 100644 --- a/backend.cpp +++ b/backend.cpp @@ -202,7 +202,10 @@ public: this->symbols[idx] = obj; } node *load(uint32_t idx) { - return this->symbols[idx]; + node *ret = this->symbols[idx]; + if (!ret) + error("name is not defined"); + return ret; } }; diff --git a/transform.py b/transform.py index 1511d79..3635033 100644 --- a/transform.py +++ b/transform.py @@ -586,7 +586,7 @@ with open(sys.argv[2], 'w') as f: f.write('%s\n' % func) f.write('int main(int argc, char **argv) {\n') - f.write(' node *global_syms[%s];\n' % (transformer.global_sym_count)) + f.write(' node *global_syms[%s] = {0};\n' % (transformer.global_sym_count)) f.write(' context ctx(%s, global_syms), *globals = &ctx;\n' % (transformer.global_sym_count)) f.write(' init_context(&ctx, argc, argv);\n') -- 2.11.4.GIT