[poppler] poppler/SignatureHandler.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Feb 2 19:34:40 UTC 2022
poppler/SignatureHandler.cc | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
New commits:
commit 373bad5cd0a8996beed271228e9131833a7ba8ce
Author: Albert Astals Cid <aacid at kde.org>
Date: Wed Feb 2 20:22:21 2022 +0100
Be more resiliant against env variables not being set
getenv can return null so don't crash (constructing a std::string from
null is not good) if that happens
diff --git a/poppler/SignatureHandler.cc b/poppler/SignatureHandler.cc
index 22a620c6..3032623a 100644
--- a/poppler/SignatureHandler.cc
+++ b/poppler/SignatureHandler.cc
@@ -669,9 +669,17 @@ std::unique_ptr<X509CertificateInfo> SignatureHandler::getCertificateInfo() cons
static std::optional<std::string> getDefaultFirefoxCertDB()
{
#ifdef _WIN32
- const std::string firefoxPath = std::string(getenv("USERPROFILE")) + "/AppData/Roaming/Mozilla/Firefox/Profiles/";
+ const char *env = getenv("USERPROFILE");
+ if (!env) {
+ return {};
+ }
+ const std::string firefoxPath = std::string(env) + "/AppData/Roaming/Mozilla/Firefox/Profiles/";
#else
- const std::string firefoxPath = std::string(getenv("HOME")) + "/.mozilla/firefox/";
+ const char *env = getenv("HOME");
+ if (!env) {
+ return {};
+ }
+ const std::string firefoxPath = std::string(env) + "/.mozilla/firefox/";
#endif
GDir firefoxDir(firefoxPath.c_str());
More information about the poppler
mailing list