← Commit list

57e746781

Mike Frysinger
Mike Frysinger
2009-04-09
FAILED Duration: 33s

Subject

dont crash if the variable we do substitution on is not set

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+14 -12
@@ -2025,18 +2025,20 @@ static int expand_vars_to_list(o_string *output, int n, char *arg, char or_mask)
debug_printf_expand("%s\n", val);
} else if (exp_off) {
if (exp_op == '%' || exp_op == '#') {
- /* we need to do a pattern match */
- bool zero;
- char *loc;
- scan_t scan = pick_scan(exp_op, *exp_word, &zero);
- if (exp_op == *exp_word) /* ## or %% */
- ++exp_word;
- val = dyn_val = xstrdup(val);
- loc = scan(dyn_val, exp_word, zero);
- if (zero)
- val = loc;
- else
- *loc = '\0';
+ if (val) {
+ /* we need to do a pattern match */
+ bool zero;
+ char *loc;
+ scan_t scan = pick_scan(exp_op, *exp_word, &zero);
+ if (exp_op == *exp_word) /* ## or %% */
+ ++exp_word;
+ val = dyn_val = xstrdup(val);
+ loc = scan(dyn_val, exp_word, zero);
+ if (zero)
+ val = loc;
+ else
+ *loc = '\0';
+ }
} else {
/* we need to do an expansion */
int exp_test = (!val || (exp_null && !val[0]));