I have a piece of code which used to crash in release mode of visual studio. Though I have fixed it, I would like to know, why the crash actually happened.
There was a piece of code written in the following way.
char *output = strdup(strcat(strdup(text1),strdup(text2)));
I know it is a ridiculous piece of code, I wonder what the person was thinking when he wrote this! But my question is why didnt the code crash at this point. It crashed after 3-4 functions where called, which had multiple mallocs and free being called.
What is the reason for a code to crash at a certain point, even though the actual memory corruption was done much earlier?