Fix memory leak in segment primes