From ce12c89e6f0d05d9433982a5430f92de3a1549b2 Mon Sep 17 00:00:00 2001 From: wasiher Date: Sun, 19 Jul 2020 18:34:24 +0900 Subject: [PATCH 1/2] Removed strcpy --- Python/strdup.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Python/strdup.c b/Python/strdup.c index 6ce171b21fe6c4..c39c9ea1a15dce 100644 --- a/Python/strdup.c +++ b/Python/strdup.c @@ -4,9 +4,10 @@ char * strdup(const char *str) { if (str != NULL) { - char *copy = malloc(strlen(str) + 1); + size_t len = strlen(str) + 1; + char *copy = malloc(len); if (copy != NULL) - return strcpy(copy, str); + return memcpy(copy, str, len); } return NULL; } From c17f74012d070a81eada9e532428c39bd74758ee Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Thu, 23 Jul 2020 19:13:04 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core and Builtins/2020-07-23-19-13-03.bpo-41340.en20DT.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2020-07-23-19-13-03.bpo-41340.en20DT.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-07-23-19-13-03.bpo-41340.en20DT.rst b/Misc/NEWS.d/next/Core and Builtins/2020-07-23-19-13-03.bpo-41340.en20DT.rst new file mode 100644 index 00000000000000..dbc3d3400b9b0d --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2020-07-23-19-13-03.bpo-41340.en20DT.rst @@ -0,0 +1 @@ +Optimized strdup \ No newline at end of file