Я создал полностью компилируемый пример:
#include <string>
#include <iostream>
#include <cstdio>
std::string Change( char * ) {
std::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;
}
int main()
{
char a[]={"abaaaaa2"};
std::cout<<Change(a)<<std::endl;
}
При работе под Valgrind утечки не обнаруживаются:
==16829==
==16829== HEAP SUMMARY:
==16829== in use at exit: 0 bytes in 0 blocks
==16829== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==16829==
==16829== All heap blocks were freed -- no leaks are possible
==16829==
==16829== For counts of detected and suppressed errors, rerun with: -v
==16829== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 15 from 8)