protecting against malloc failure in parser

This commit is contained in:
Antoine Riard 2017-03-18 19:20:00 +01:00
parent 6f58bb20b3
commit 137aa1d976
6 changed files with 11 additions and 9 deletions

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
/* Updated: 2017/03/18 18:42:58 by ariard ### ########.fr */
/* Updated: 2017/03/18 19:05:37 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */
/* Updated: 2017/03/17 21:30:29 by jhalford ### ########.fr */
/* Updated: 2017/03/18 19:08:44 by ariard ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 15:58:38 by ariard #+# #+# */
/* Updated: 2017/03/18 17:28:43 by ariard ### ########.fr */
/* Updated: 2017/03/18 19:18:21 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -375,7 +375,7 @@ int aggregate_sym(t_list **stack, t_sym *new_sym, t_parstate *state)
t_sym *head;
int i;
if (!*stack || !*new_sym || !*state)
if (!*stack || !new_sym || !*new_sym || !*state)
return (1);
i = -1;
head = (*stack)->content;

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/11 16:17:38 by ariard #+# #+# */
/* Updated: 2017/03/18 17:08:53 by ariard ### ########.fr */
/* Updated: 2017/03/18 19:18:34 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -37,10 +37,10 @@ int ft_parse(t_btree **ast, t_list **token, t_parser *parser)
if (pop_heredoc(token))
return (0);
while (*token)
while (parser && token && *token)
{
produce_sym(&parser->stack, parser->new_sym, token);
if (eval_sym(&parser->stack, *parser->new_sym))
if (parser->new_sym && eval_sym(&parser->stack, *parser->new_sym))
return ((parser->state = ERROR));
if (aggregate_sym(&parser->stack, parser->new_sym, &parser->state))
return (0);

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 16:21:05 by ariard #+# #+# */
/* Updated: 2017/03/18 19:00:17 by ariard ### ########.fr */
/* Updated: 2017/03/18 19:15:41 by ariard ### ########.fr */
/* */
/* ************************************************************************** */
@ -29,6 +29,8 @@ int pop_heredoc(t_list **lst)
t_list **head;
t_redir *redir;
if (!lst || !*lst)
return (0);
token = (*lst)->content;
if (token->type == HEREDOCDATA
&& data_singleton()->parser.heredoc_queue != NULL)

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/09 16:48:30 by ariard #+# #+# */
/* Updated: 2017/03/11 16:22:32 by ariard ### ########.fr */
/* Updated: 2017/03/18 19:15:39 by ariard ### ########.fr */
/* */
/* ************************************************************************** */