I'm writing a C program on my mac and I made something basic, but I got this error. I have a struct with a char pointer in it to hold a short description. In my main class I made a pointer to this struct and then another for the char pointer within the struct. When I free the char pointer in the struct, my terminal throws out some error message about a pointer being freed that was not allocated. The error is not present if I comment that line out, so I'm pretty sure it's that line. I'll include the code causing this odd issue.
Chair *chair = (Chair*)malloc(sizeof(Chair));
chair->color = (char*)malloc(sizeof(char)*4);
chair->color = "blue";
printf("This chair is %s", chair->color);
free(chair->color);
free(chair);
return 0;
When I searched for this, it always came to user error of not mallocing or "double free errors". I'm pretty sure I used malloc and that there isn't a glaringly obvious problem in those 6 lines.