From 24c6210ef27aa232be7c1582a27ec4d4e33b14c9 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 6 Jul 2020 09:07:12 +0200 Subject: [PATCH] Fix don't set LC_NUMERIC twice --- lib/base/process.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/base/process.cpp b/lib/base/process.cpp index 6f36da913..d64dd3928 100644 --- a/lib/base/process.cpp +++ b/lib/base/process.cpp @@ -100,23 +100,30 @@ static Value ProcessSpawnImpl(struct msghdr *msgh, const Dictionary::Ptr& reques envc++; auto **envp = new char *[envc + (extraEnvironment ? extraEnvironment->GetLength() : 0) + 2]; + const char* lcnumeric = "LC_NUMERIC="; + int j = 0; - for (int i = 0; i < envc; i++) - envp[i] = strdup(environ[i]); + for (int i = 0; i < envc; i++) { + if (strncmp(environ[i], lcnumeric, strlen(lcnumeric)) == 0) { + continue; + } + + envp[j] = strdup(environ[i]); + ++j; + } if (extraEnvironment) { ObjectLock olock(extraEnvironment); - int index = envc; for (const Dictionary::Pair& kv : extraEnvironment) { String skv = kv.first + "=" + Convert::ToString(kv.second); - envp[index] = strdup(skv.CStr()); - index++; + envp[j] = strdup(skv.CStr()); + j++; } } - envp[envc + (extraEnvironment ? extraEnvironment->GetLength() : 0)] = strdup("LC_NUMERIC=C"); - envp[envc + (extraEnvironment ? extraEnvironment->GetLength() : 0) + 1] = nullptr; + envp[j] = strdup("LC_NUMERIC=C"); + envp[j + 1] = nullptr; extraEnvironment.reset();