Segmentation fault in C with malloc
问题 I'm getting a segmentation fault for the below scenario: When reading from a file for a list of ip addresses, i store the IP ADDRESS and port in a link list. As my while loops for file reading repeats itself, as per link list logic - when i malloc my temp pointer again i face segmentation fault. Please find below the code snippet: struct woker_conf { int port; char *ip_address; struct worker_conf *next; } *head; void open(int8_t nbrwrk) { FILE *fp = NULL; char line[1024] = {0}; int i = 1;