我有一个测试功能
std:string tmp(length * 2, 'a');
int len = tmp.length();
char *ptr = new char[len + 1];
strncpy(ptr, tmp.c_str(), len);
ptr[len + 1] ='\0';
data_log(ptr);
delete ptr;
我收到了valgrind错误
Conditional jump or move depends on uninitialised value(s) on line data_log(ptr)
我尝试了各种选项但失败了。请有人帮忙吗?