Skip to content

Commit

Permalink
pythongh-127864: Fix compiler warning (-Wstringop-truncation) (python…
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasr8 authored Dec 16, 2024
1 parent 52d552c commit 0816738
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 0816738

Please sign in to comment.