> if(ports) {
> for (i=0;ports[i];i++)
> free(ports)
> }
if you read it carefully, you will see there is a semi-colon at the end
of the for() expression. this is a counting loop, and then ports is
freed. i have changed to code to use {} instead of the semi-colon to
make this more obvious.
--p