Fix memory allocation bug in List class.