Let me know if i need to post the entire code here thank you for your help.
int sum_LL(node* ptr) { int ret = 0; while(ptr) { ret += ptr->val;//segmentation