free() on stack memory
Posted
by vidicon
on Stack Overflow
See other posts from Stack Overflow
or by vidicon
Published on 2010-04-22T19:04:59Z
Indexed on
2010/04/22
22:43 UTC
Read the original article
Hit count: 470
I'm supporting some c code on Solaris, and I've seen something weird at least I think it is:
char new_login[64];
...
strcpy(new_login, (char *)login);
...
free(new_login);
My understanding is that since the variable is a local array the memory comes from the stack and does not need to be freed, and moreover since no malloc/calloc/realloc was used the behaviour is undefined.
This is a real-time system so I think it is a waste of cycles. Am I missing something obvious?
© Stack Overflow or respective owner