Move the free(parser); into the if block, no reason to free if it's NULL