Fix MakeGen crashing when entering invalid filepaths in dependency
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# This Makefile was generated using MakeGen v1.3.0 made by Tim Håkansson
|
# This Makefile was generated using MakeGen v1.3.2 made by Tim Håkansson
|
||||||
# and is licensed under MIT. Full source of the project can be found at
|
# and is licensed under MIT. Full source of the project can be found at
|
||||||
# https://github.com/Thraix/MakeGen
|
# https://github.com/Thraix/MakeGen
|
||||||
CC=@g++
|
CC=@g++
|
||||||
|
|||||||
+1
-1
@@ -19,5 +19,5 @@
|
|||||||
<srcdir>src/</srcdir>
|
<srcdir>src/</srcdir>
|
||||||
</configuration>
|
</configuration>
|
||||||
<target>Release</target>
|
<target>Release</target>
|
||||||
<version>v1.3.1</version>
|
<version>v1.3.2</version>
|
||||||
</makegen>
|
</makegen>
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@
|
|||||||
// Release, should be backwards compatible with any minor version
|
// Release, should be backwards compatible with any minor version
|
||||||
#define MAKEGEN_VERSION_RELEASE 3
|
#define MAKEGEN_VERSION_RELEASE 3
|
||||||
// Minor changes, generally bug fixes
|
// Minor changes, generally bug fixes
|
||||||
#define MAKEGEN_VERSION_MINOR 1
|
#define MAKEGEN_VERSION_MINOR 2
|
||||||
|
|
||||||
#define MAKEGEN_VERSION ("v" STR(MAKEGEN_VERSION_MAJOR) "." STR(MAKEGEN_VERSION_RELEASE) "." STR(MAKEGEN_VERSION_MINOR))
|
#define MAKEGEN_VERSION ("v" STR(MAKEGEN_VERSION_MAJOR) "." STR(MAKEGEN_VERSION_RELEASE) "." STR(MAKEGEN_VERSION_MINOR))
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -333,6 +333,8 @@ std::optional<ConfigFile> ConfigFile::GetConfigFile(const std::string& filepath)
|
|||||||
std::optional<ConfigFile> ConfigFile::GetConfigFile(const std::string& filepath, std::map<std::string, ConfigFile>& loadedConfigs)
|
std::optional<ConfigFile> ConfigFile::GetConfigFile(const std::string& filepath, std::map<std::string, ConfigFile>& loadedConfigs)
|
||||||
{
|
{
|
||||||
std::string realPath = FileUtils::GetRealPath(filepath);
|
std::string realPath = FileUtils::GetRealPath(filepath);
|
||||||
|
if(realPath == "")
|
||||||
|
return {};
|
||||||
auto it = loadedConfigs.find(realPath);
|
auto it = loadedConfigs.find(realPath);
|
||||||
if(it != loadedConfigs.end())
|
if(it != loadedConfigs.end())
|
||||||
{
|
{
|
||||||
@@ -489,7 +491,7 @@ ConfigFile ConfigFile::Gen()
|
|||||||
configuration.AddXMLObject({"dependency",{},*it});
|
configuration.AddXMLObject({"dependency",{},*it});
|
||||||
|
|
||||||
makegen.AddXMLObject(configuration);
|
makegen.AddXMLObject(configuration);
|
||||||
return ConfigFile{makegen, FileUtils::GetRealPath("./")};
|
return ConfigFile{makegen, FileUtils::GetRealPath(".")};
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigFile::Save() const
|
void ConfigFile::Save() const
|
||||||
|
|||||||
+9
-1
@@ -59,14 +59,22 @@ struct FileUtils
|
|||||||
static std::string GetRealPath(const std::string& filename)
|
static std::string GetRealPath(const std::string& filename)
|
||||||
{
|
{
|
||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
|
if(access(filename.c_str(), F_OK ) != -1)
|
||||||
|
{
|
||||||
char* path = realpath(filename.c_str(), NULL);
|
char* path = realpath(filename.c_str(), NULL);
|
||||||
std::string sPath = path;
|
std::string sPath = path;
|
||||||
sPath+="/";
|
sPath+="/";
|
||||||
free(path);
|
free(path);
|
||||||
return sPath;
|
return sPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_ERROR("Directory doesn't exist: ", filename);
|
||||||
|
return "";
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
LOG_ERROR("GetRealPath not supported");
|
LOG_ERROR("GetRealPath not supported");
|
||||||
return filename;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string GetRelativePath(std::string from, std::string to)
|
static std::string GetRelativePath(std::string from, std::string to)
|
||||||
|
|||||||
Reference in New Issue
Block a user