Skip to content

Commit 0816738

Browse files
authored
gh-127864: Fix compiler warning (-Wstringop-truncation) (GH-127878)
1 parent 52d552c commit 0816738

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Python/import.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,9 +1176,10 @@ hashtable_key_from_2_strings(PyObject *str1, PyObject *str2, const char sep)
11761176
return NULL;
11771177
}
11781178

1179-
strncpy(key, str1_data, str1_len);
1179+
memcpy(key, str1_data, str1_len);
11801180
key[str1_len] = sep;
1181-
strncpy(key + str1_len + 1, str2_data, str2_len + 1);
1181+
memcpy(key + str1_len + 1, str2_data, str2_len);
1182+
key[size - 1] = '\0';
11821183
assert(strlen(key) == size - 1);
11831184
return key;
11841185
}

0 commit comments

Comments
 (0)