← Commit list

5c2c2916f

Denys Vlasenko
Denys Vlasenko
2025-08-18
SUCCESS Duration: 205s

Subject

hush: do not SEGV on if { echo foo; } then { echo bar; } fi

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/hush.c+4 -5
@@ -4202,6 +4202,10 @@ static void initialize_context(struct parse_context *ctx)
* ctx->command = &ctx->pipe->cmds[0];
*/
done_command(ctx);
+ /* If very first arg is "" or '', ctx.word.data may end up NULL.
+ * Prevent this:
+ */
+ ctx->word.data = xzalloc(1); /* start as "", not as NULL */
}
/* If a reserved word is found and processed, parse context is modified
@@ -5840,11 +5844,6 @@ static struct pipe *parse_stream(char **pstring,
enable_all_aliases();
initialize_context(&ctx);
- /* If very first arg is "" or '', ctx.word.data may end up NULL.
- * Preventing this:
- */
- ctx.word.data = xzalloc(1); /* start as "", not as NULL */
-
/* We used to separate words on $IFS here. This was wrong.
* $IFS is used only for word splitting when $var is expanded,
* here we should use blank chars as separators, not $IFS