From 9f249970b0c921e9ce34e11f5434d2c7779c95b6 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Fri, 15 Dec 2017 21:06:27 -0800 Subject: [PATCH] Ensure DEFAULT_RESOURCE_DIRECTORY is a string. --- src/messages/initialize.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/messages/initialize.cc b/src/messages/initialize.cc index 016ad68c..4fc49675 100644 --- a/src/messages/initialize.cc +++ b/src/messages/initialize.cc @@ -5,6 +5,9 @@ #include +#define _STRINGIFY(x) #x +#define ENSURE_STRING_MACRO_ARGUMENT(x) _STRINGIFY(x) + namespace { struct Ipc_InitializeRequest : public IpcMessage { const static IpcId kIpcId = IpcId::Initialize; @@ -86,11 +89,12 @@ struct InitializeHandler : BaseMessageHandler { // Ensure there is a resource directory. if (config->resourceDirectory.empty()) { - std::string defaultResourceDirectory = std::string(DEFAULT_RESOURCE_DIRECTORY); + std::string defaultResourceDirectory = std::string( + ENSURE_STRING_MACRO_ARGUMENT(DEFAULT_RESOURCE_DIRECTORY)); if (defaultResourceDirectory.find("..") != std::string::npos) { std::string executablePath = GetExecutablePath(); size_t pos = executablePath.find_last_of('/'); - config->resourceDirectory = executablePath.substr(0, pos+1); + config->resourceDirectory = executablePath.substr(0, pos + 1); config->resourceDirectory += defaultResourceDirectory; } else { config->resourceDirectory = defaultResourceDirectory;