I have a inline function defined as following:
inline string Change(char *pointer) {
string str;
char temp[32] = "";
sprintf(temp,"%c:%c:%c:%c:%c:%c", //line 1
temp[0],temp[1],temp[2],
temp[3],temp[4],temp[5],
);
str = temp;
return str;
}
when I use memory leak tool to check it, it indicates line 1(marked above) is memory leak.
What is the problem of the above code?
I created fully compilable example:
When running under valgrind, I get no leaks detected: