Only free(origin) when we are done using it.
Fix compilation error
free(origin) also when there's an error