Fixed double free problem with segments