Skip to content

Commit

Permalink
Add check after getting current attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
andy5995 committed Feb 29, 2024
1 parent 9c0e81e commit cfa4ac0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion canfigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,17 @@ canfigger_free_current_attr_str_advance(struct attributes *attributes,
attributes->iter_ptr = grab_str_segment(attributes->iter_ptr,
&attributes->current, '\n');

*attr = attributes->current;
if (*attributes->current)
{
*attr = attributes->current;
return;
}

// If we're here, that means strdup() failed to allocate memory in grab_str_segment()
// If an expected attribute isn't returned, the caller may want to terminate
// the remainder of the loop that's iterating through the entire linked list
// and exit the program.
*attr = NULL;
return;
}

Expand Down

0 comments on commit cfa4ac0

Please sign in to comment.