Skip to content
Snippets Groups Projects
Commit cd344e3a authored by Sylvain Joubert's avatar Sylvain Joubert Committed by Brad King
Browse files

create_test_sourcelist: Use safer strncpy instead of strcpy

Clang-tidy advises to use a safer function in place of strcpy.
This should avoid such warnings in user build using clang-tidy.
parent 98caa14c
No related branches found
No related tags found
No related merge requests found
......@@ -33,19 +33,21 @@ static functionMapEntry cmakeGeneratedFunctionMapEntries[] = {
static char* lowercase(const char *string)
{
char *new_string, *p;
size_t stringSize = 0;
#ifdef __cplusplus
new_string = static_cast<char *>(malloc(sizeof(char) *
static_cast<size_t>(strlen(string) + 1)));
stringSize = static_cast<size_t>(strlen(string) + 1);
new_string = static_cast<char *>(malloc(sizeof(char) * stringSize));
#else
new_string = (char *)(malloc(sizeof(char) * (size_t)(strlen(string) + 1)));
stringSize = (size_t)(strlen(string) + 1);
new_string = (char *)(malloc(sizeof(char) * stringSize));
#endif
if (!new_string)
{
return 0;
}
strcpy(new_string, string);
strncpy(new_string, string, stringSize);
p = new_string;
while (*p != 0)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment