Skip to content

Commit

Permalink
FIX: segfault
Browse files Browse the repository at this point in the history
the segfault was if the first line have a le under 2
  • Loading branch information
Joan-Cordelier committed Apr 9, 2024
1 parent 7079f1e commit cf5d3c9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lst/del.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ int del(void *data)
parsing_t **list = (parsing_t **) data;
parsing_t *to_rm = NULL;

if ((*list)->str[0] == '#' && (*list)->str[1] != '#'){
if (my_strlen((*list)->str) > 1 &&
((*list)->str[0] == '#' && (*list)->str[1] != '#')){
to_rm = (*list)->next;
free((*list)->str);
free((*list));
(*list) = to_rm;
}
for (parsing_t *tmp = *list; tmp->next != NULL; tmp = tmp->next) {
if (tmp->next->str[0] == '#' && tmp->next->str[1] != '#') {
if (my_strlen(tmp->next->str) > 1 &&
(tmp->next->str[0] == '#' && tmp->next->str[1] != '#')) {
to_rm = tmp->next->next;
free(tmp->next->str);
free(tmp->next);
Expand Down

0 comments on commit cf5d3c9

Please sign in to comment.