summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorTomas R. <tomas.roun8@gmail.com>2024-12-16 16:57:18 (GMT)
committerGitHub <noreply@github.com>2024-12-16 16:57:18 (GMT)
commit081673801e3d47d931d2e2b6a4a1515e1207d938 (patch)
treeaf2425f600a24b8d18a9c68dfde4f6e90ed88d46 /Python
parent52d552cda7614c7aa9f08b680089c630587e747f (diff)
downloadcpython-081673801e3d47d931d2e2b6a4a1515e1207d938.zip
cpython-081673801e3d47d931d2e2b6a4a1515e1207d938.tar.gz
cpython-081673801e3d47d931d2e2b6a4a1515e1207d938.tar.bz2
gh-127864: Fix compiler warning (-Wstringop-truncation) (GH-127878)
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/import.c b/Python/import.c
index f3511aa..a9282dd 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -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;
}