]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-127864: Fix compiler warning (-Wstringop-truncation) (GH-127878)
authorTomas R. <tomas.roun8@gmail.com>
Mon, 16 Dec 2024 16:57:18 +0000 (17:57 +0100)
committerGitHub <noreply@github.com>
Mon, 16 Dec 2024 16:57:18 +0000 (11:57 -0500)
Python/import.c

index f3511aaf7b801010817f86cc0d9ddaa24f2d8036..a9282dde63395905eab947d88620407ee81eea29 100644 (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;
 }