segfaults on free are often double-free's (where you've tried to "free" something that's already been free'd) or where something was NEVER malloc'd in the first place. You're going to need to trace it in a debugger for a specific answer, unless you post the FULL code so that someone else can have a look in a debugger for you. Chances are, you never initialise something, you run off the end of your list of nodes and try to free memory that was never meant to be used, or you've somehow freed the same node twice.