diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2015-11-05 07:56:47 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-11-05 07:56:51 +0100 |
commit | 664ca396281d3f5aa31605eaa9891c3d834dd99a (patch) | |
tree | f7960f4d5c40d4f53f7aa7259a6faa4834fe443c /common/hush.c | |
parent | ed395e4df1ed4188cbb52870b8ad4b677be4cca0 (diff) | |
download | barebox-664ca396281d3f5aa31605eaa9891c3d834dd99a.tar.gz barebox-664ca396281d3f5aa31605eaa9891c3d834dd99a.tar.xz |
hush: Add missing initialize_context() in some places
Before a context can be used it must be initialized. This was forgotten
in several places. Add the missing calls to initialize_context().
This fixes crashes when sourcing empty files
Reported-by: Wjatscheslaw Stoljarski <wjatscheslaw.stoljarski@kiwigrid.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/hush.c')
-rw-r--r-- | common/hush.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/common/hush.c b/common/hush.c index abe87137b5..084dd858dc 100644 --- a/common/hush.c +++ b/common/hush.c @@ -814,6 +814,8 @@ static int run_pipe_real(struct p_context *ctx, struct pipe *pi) char * str = NULL; struct p_context ctx1; + initialize_context(&ctx1); + str = make_string((child->argv + i)); rcode = parse_string_outer(&ctx1, str, FLAG_EXIT_FROM_LOOP | FLAG_REPARSING); release_context(&ctx1); @@ -1866,6 +1868,8 @@ int run_command(const char *cmd) struct p_context ctx; int ret; + initialize_context(&ctx); + ret = parse_string_outer(&ctx, cmd, FLAG_PARSE_SEMICOLON); release_context(&ctx); @@ -1889,6 +1893,8 @@ static int source_script(const char *path, int argc, char *argv[]) char *script; int ret; + initialize_context(&ctx); + ctx.global_argc = argc; ctx.global_argv = argv; |