gh-127864: Fix compiler warning (-Wstringop-truncation) (GH-127878)

This commit is contained in:
Tomas R. 2024-12-16 17:57:18 +01:00 committed by GitHub
parent 52d552cda7
commit 081673801e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1176,9 +1176,10 @@ hashtable_key_from_2_strings(PyObject *str1, PyObject *str2, const char sep)
return NULL;
}
strncpy(key, str1_data, str1_len);
memcpy(key, str1_data, str1_len);
key[str1_len] = sep;
strncpy(key + str1_len + 1, str2_data, str2_len + 1);
memcpy(key + str1_len + 1, str2_data, str2_len);
key[size - 1] = '\0';
assert(strlen(key) == size - 1);
return key;
}