Merge topic 'test-driver-clang-tidy'
cd344e3a
create_test_sourcelist: Use safer strncpy instead of strcpy
This commit is contained in:
commit
d65584f7a3
|
@ -33,19 +33,21 @@ static functionMapEntry cmakeGeneratedFunctionMapEntries[] = {
|
||||||
static char* lowercase(const char *string)
|
static char* lowercase(const char *string)
|
||||||
{
|
{
|
||||||
char *new_string, *p;
|
char *new_string, *p;
|
||||||
|
size_t stringSize = 0;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
new_string = static_cast<char *>(malloc(sizeof(char) *
|
stringSize = static_cast<size_t>(strlen(string) + 1);
|
||||||
static_cast<size_t>(strlen(string) + 1)));
|
new_string = static_cast<char *>(malloc(sizeof(char) * stringSize));
|
||||||
#else
|
#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
|
#endif
|
||||||
|
|
||||||
if (!new_string)
|
if (!new_string)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
strcpy(new_string, string);
|
strncpy(new_string, string, stringSize);
|
||||||
p = new_string;
|
p = new_string;
|
||||||
while (*p != 0)
|
while (*p != 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue