From: Christopher Dykes Date: Fri, 12 Aug 2016 21:29:28 +0000 (-0700) Subject: Don't call strlen(nullptr) in mkdtemp and mkstemp X-Git-Tag: v2016.08.15.00~2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3062d1cda02b34872e9d046ee31b6d753a8422fd;p=folly.git Don't call strlen(nullptr) in mkdtemp and mkstemp Summary: Because it's a terrible idea. It also didn't work. Reviewed By: yfeldblum Differential Revision: D3711443 fbshipit-source-id: 48ab77dfff005347c72daeaf0d27390bb86f4bd1 --- diff --git a/folly/portability/Stdlib.cpp b/folly/portability/Stdlib.cpp index 049443a2..85cbe0b0 100644 --- a/folly/portability/Stdlib.cpp +++ b/folly/portability/Stdlib.cpp @@ -19,6 +19,7 @@ #ifdef _WIN32 #include #include + #include #include #include @@ -31,7 +32,7 @@ char* mktemp(char* tn) { return _mktemp(tn); } // still working just fine. char* mkdtemp(char* tn) { char* ptr = nullptr; - auto len = strlen(ptr); + auto len = strlen(tn); int ret = 0; do { strcpy(tn + len - 6, "XXXXXX"); @@ -49,7 +50,7 @@ char* mkdtemp(char* tn) { int mkstemp(char* tn) { char* ptr = nullptr; - auto len = strlen(ptr); + auto len = strlen(tn); int ret = 0; do { strcpy(tn + len - 6, "XXXXXX");