diff --git a/src/parse.cpp b/src/parse.cpp index 92e070d..2891aa9 100644 --- a/src/parse.cpp +++ b/src/parse.cpp @@ -1414,6 +1414,10 @@ std::pair parse_if(parse_context ctx) newctx.has_errored=true; } ctx = newctx; + if(ctx.i >= ctx.size) + { + return std::make_pair(ret, ctx); + } if(word == "fi") break; @@ -1597,6 +1601,7 @@ std::pair parse_block(parse_context ctx) else if(is_in_vector(word, out_reserved_words)) // is a reserved word { parse_error( strf("Unexpected '%s'", word.c_str())+expecting(ctx.expecting) , ctx); + ctx.i+=word.size(); } // end reserved words else if( word == "function" ) // bash style function @@ -1651,7 +1656,7 @@ std::pair parse_block(parse_context ctx) } - if(ret->type != block::block_cmd) + if(ret!=nullptr && ret->type != block::block_cmd) { uint32_t j=skip_chars(ctx, SPACES); ctx.i=j;