From b976487b611fabb2b07c2e4dee197211d080fbb0 Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Thu, 12 Jul 2018 21:42:00 -0700 Subject: [PATCH] [MirrorOrch]: Fix bug when NULL is returned from the getenv function (#537) This fixes the error: Failed due to exception: basic_string::_S_construct null not valid when the environment variable 'platform' is not set. Signed-off-by: Shu0T1an ChenG --- orchagent/mirrororch.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/orchagent/mirrororch.cpp b/orchagent/mirrororch.cpp index bfd53636fc16..4c0380f1d3ee 100644 --- a/orchagent/mirrororch.cpp +++ b/orchagent/mirrororch.cpp @@ -194,7 +194,8 @@ void MirrorOrch::createEntry(const string& key, const vector& d { SWSS_LOG_ENTER(); - MirrorEntry entry(getenv("platform")); + string platform = getenv("platform") ? getenv("platform") : ""; + MirrorEntry entry(platform); for (auto i : data) {