Are you freeing anything that's passed to dxf_do_export() ? You can build pcb with debuggging (look for -O in the Makefile, add -g and remove -O). Then you can run it under gdb and type "where" to see what it's trying to free.