fix bug in codegen: foreach/forindex(id;vec/hash) may cause segmentation fault because of incorrect generated operand

This commit is contained in:
ValKmjolnir
2022-04-16 19:45:55 +08:00
parent ca073499ae
commit fc25dd69e1
5 changed files with 88 additions and 14 deletions
+8 -1
View File
@@ -126,9 +126,16 @@ public:
void nasal_lexer::open(const std::string& file)
{
struct stat buffer;
if(stat(file.c_str(),&buffer)==0 && !S_ISREG(buffer.st_mode))
{
nerr.err("lexer","<"+file+"> is not a regular file.");
res="";
return;
}
std::ifstream fin(file,std::ios::binary);
if(fin.fail())
nerr.err("lexer","cannot open file <"+file+">.");
nerr.err("lexer","failed to open <"+file+">.");
else
nerr.load(file);
std::stringstream ss;