Assigning a value to a pointer is NOT allocating it. You can only free a pointer that your have gotten from malloc or its variants.