correct = correct_str(&corr, parser->correct_variables[i], parser_tokval(parser));
if (strcmp(correct, parser_tokval(parser))) {
break;
- } else if (correct) {
+ } else {
mem_d(correct);
correct = NULL;
}
}
unary = (ast_unary*)cond;
- while (ast_istype(cond, ast_unary) && unary->op == INSTR_NOT_F)
+ /* ast_istype dereferences cond, should test here for safety */
+ while (cond && ast_istype(cond, ast_unary) && unary->op == INSTR_NOT_F)
{
cond = unary->operand;
unary->operand = NULL;
data->pipes [0] = inhandle [1];
data->pipes [1] = outhandle[0];
data->pipes [2] = errhandle[0];
+
data->handles[0] = fdopen(inhandle [1], "w");
data->handles[1] = fdopen(outhandle[0], mode);
data->handles[2] = fdopen(errhandle[0], mode);
close(errhandle[0]);
/* see piping documentation for this sillyness :P */
- close(0); (void)!dup(inhandle [0]);
- close(1); (void)!dup(outhandle[1]);
- close(2); (void)!dup(errhandle[1]);
+ dup2(inhandle [0], 0);
+ dup2(outhandle[1], 1);
+ dup2(errhandle[1], 2);
execvp(*argv, argv);
exit(EXIT_FAILURE);
task_popen_error_1: close(inhandle [0]), close(inhandle [1]);
task_popen_error_0:
- if (argv)
- vec_free(argv);
+ vec_free(argv);
return NULL;
}
return true;
failure:
- if (back)
- mem_d (back);
+ mem_d (back);
return false;
}