The t_colornames array needs to have its entries freed since they will be populated with the names of the colors (if names were given). (In fact you could free the colorname entries in the above loop)