Funcion en C++ a veces retorna string vacio?
No conozco mucho el lenguaje c++, necesito para un script una función que me sanee los inputs, y esta es la que me pasaron. La pruebo a veces funciona pero a veces retorna un string vacío. ¿Alguien me podría ayudar?
char* sanitize(std::string input) {
std::string new_string = std::regex_replace(input,std::regex{"'"},"´");
new_string = std::regex_replace(new_string, std::regex{'"'},"´´");
new_string = std::regex_replace(new_string, std::regex(R"(\\)"), R"()");
new_string = std::regex_replace(new_string, std::regex{'<'},"");
new_string = std::regex_replace(new_string, std::regex{'>'},"");
new_string = std::regex_replace(new_string, std::regex{'-'},"");
char* buffer = (char*)malloc(new_string.length());
strcpy(buffer,new_string.c_str());
return buffer;
}