mirror of
https://github.com/alterware/aw-installer.git
synced 2025-04-19 08:02:53 +00:00
fix: address a potential memory leak
This commit is contained in:
parent
f3adaf4847
commit
b08d201b87
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -4,7 +4,7 @@
|
|||||||
[submodule "deps/curl"]
|
[submodule "deps/curl"]
|
||||||
path = deps/curl
|
path = deps/curl
|
||||||
url = https://github.com/curl/curl.git
|
url = https://github.com/curl/curl.git
|
||||||
branch = curl-8_5_0
|
branch = curl-8_7_1
|
||||||
[submodule "deps/rapidjson"]
|
[submodule "deps/rapidjson"]
|
||||||
path = deps/rapidjson
|
path = deps/rapidjson
|
||||||
url = https://github.com/Tencent/rapidjson.git
|
url = https://github.com/Tencent/rapidjson.git
|
||||||
|
10
README.md
10
README.md
@ -8,16 +8,20 @@ This is the tool we use to pull changes made from the release page of some of ou
|
|||||||
- Install [Premake5][premake5-link] and add it to your system PATH
|
- Install [Premake5][premake5-link] and add it to your system PATH
|
||||||
- Clone this repository using [Git][git-link]
|
- Clone this repository using [Git][git-link]
|
||||||
- Update the submodules using ``git submodule update --init --recursive``
|
- Update the submodules using ``git submodule update --init --recursive``
|
||||||
- Run Premake with either of these two options ``premake5 vs2022`` (Windows) or ``premake5 gmake2`` (Linux/macOS)
|
- Run Premake with either of these two options ``premake5 vs2022`` (for Windows) or ``premake5 gmake2`` (for Linux/macOS)
|
||||||
|
- On Windows, build the project via the solution file in ``build\aw-installer.sln``
|
||||||
|
- On Linux/macOS, build the project using [Make][make-link] via the ``Makefile`` located in the ``build`` folder
|
||||||
|
|
||||||
**IMPORTANT**
|
**IMPORTANT**
|
||||||
Requirements for Unix systems:
|
Requirements for Unix systems:
|
||||||
- Compilation: Please use Clang as the preferred compiler
|
- Compilation: Please use Clang
|
||||||
- Dependencies: Ensure the LLVM C++ Standard library is installed
|
- Dependencies: Ensure the LLVM [C++ Standard library][libcxx-link] is installed
|
||||||
- Alternative compilers: If you opt for a different compiler such as GCC, use the [Mold][mold-link] linker
|
- Alternative compilers: If you opt for a different compiler such as GCC, use the [Mold][mold-link] linker
|
||||||
- Customization: Modifications to the Premake5.lua script may be required
|
- Customization: Modifications to the Premake5.lua script may be required
|
||||||
- Platform support: Details regarding supported platforms are available in [build.yml](.github/workflows/build.yml)
|
- Platform support: Details regarding supported platforms are available in [build.yml](.github/workflows/build.yml)
|
||||||
|
|
||||||
[premake5-link]: https://premake.github.io
|
[premake5-link]: https://premake.github.io
|
||||||
[git-link]: https://git-scm.com
|
[git-link]: https://git-scm.com
|
||||||
|
[make-link]: https://en.wikipedia.org/wiki/Make_(software)
|
||||||
|
[libcxx-link]: https://libcxx.llvm.org/
|
||||||
[mold-link]: https://github.com/rui314/mold
|
[mold-link]: https://github.com/rui314/mold
|
||||||
|
2
deps/curl
vendored
2
deps/curl
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 7161cb17c01dcff1dc5bf89a18437d9d729f1ecd
|
Subproject commit de7b3e89218467159a7af72d58cea8425946e97d
|
@ -46,10 +46,10 @@ namespace utils::compression
|
|||||||
|
|
||||||
z_stream& get()
|
z_stream& get()
|
||||||
{
|
{
|
||||||
return stream_; //
|
return stream_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_valid() const
|
[[nodiscard]] bool is_valid() const
|
||||||
{
|
{
|
||||||
return valid_;
|
return valid_;
|
||||||
}
|
}
|
||||||
@ -177,7 +177,7 @@ namespace utils::compression
|
|||||||
}
|
}
|
||||||
|
|
||||||
// I apologize for writing such a huge function
|
// I apologize for writing such a huge function
|
||||||
// I'm Using make_preferred() so / are converted to \\ on Windows but not on POSIX
|
// I'm using make_preferred() so / are converted to \\ on Windows but not on POSIX
|
||||||
void archive::decompress(const std::string& filename, const std::filesystem::path& out_dir)
|
void archive::decompress(const std::string& filename, const std::filesystem::path& out_dir)
|
||||||
{
|
{
|
||||||
unzFile file = unzOpen(filename.c_str());
|
unzFile file = unzOpen(filename.c_str());
|
||||||
@ -229,7 +229,7 @@ namespace utils::compression
|
|||||||
// Entry is a file. Extract it.
|
// Entry is a file. Extract it.
|
||||||
if (unzOpenCurrentFile(file) != UNZ_OK)
|
if (unzOpenCurrentFile(file) != UNZ_OK)
|
||||||
{
|
{
|
||||||
// Could not read file from the ZIP
|
unzClose(file);
|
||||||
throw std::runtime_error(string::va("Failed to read file \"%s\" from \"%s\"", out_file.c_str(), filename.c_str()));
|
throw std::runtime_error(string::va("Failed to read file \"%s\" from \"%s\"", out_file.c_str(), filename.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,6 +243,8 @@ namespace utils::compression
|
|||||||
std::ofstream out(path.make_preferred().string(), std::ios::binary | std::ios::trunc);
|
std::ofstream out(path.make_preferred().string(), std::ios::binary | std::ios::trunc);
|
||||||
if (!out.is_open())
|
if (!out.is_open())
|
||||||
{
|
{
|
||||||
|
unzCloseCurrentFile(file);
|
||||||
|
unzClose(file);
|
||||||
throw std::runtime_error("Failed to open stream");
|
throw std::runtime_error("Failed to open stream");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,6 +254,8 @@ namespace utils::compression
|
|||||||
read_bytes = unzReadCurrentFile(file, read_buffer, READ_BUFFER_SIZE);
|
read_bytes = unzReadCurrentFile(file, read_buffer, READ_BUFFER_SIZE);
|
||||||
if (read_bytes < 0)
|
if (read_bytes < 0)
|
||||||
{
|
{
|
||||||
|
unzCloseCurrentFile(file);
|
||||||
|
unzClose(file);
|
||||||
throw std::runtime_error(string::va("Error while reading \"%s\" from the archive", out_file.c_str()));
|
throw std::runtime_error(string::va("Error while reading \"%s\" from the archive", out_file.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,6 +277,7 @@ namespace utils::compression
|
|||||||
// Go the the next entry listed in the ZIP file.
|
// Go the the next entry listed in the ZIP file.
|
||||||
if ((i + 1) < global_info.number_entry)
|
if ((i + 1) < global_info.number_entry)
|
||||||
{
|
{
|
||||||
|
// According to the AI overlords I do not need to close the file with unzCloseCurrentFile here
|
||||||
if (unzGoToNextFile(file) != UNZ_OK)
|
if (unzGoToNextFile(file) != UNZ_OK)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -8,12 +8,12 @@ namespace utils::io
|
|||||||
{
|
{
|
||||||
bool remove_file(const std::string& file)
|
bool remove_file(const std::string& file)
|
||||||
{
|
{
|
||||||
return remove(file.c_str()) == 0;
|
return std::remove(file.c_str()) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool move_file(const std::string& src, const std::string& target)
|
bool move_file(const std::string& src, const std::string& target)
|
||||||
{
|
{
|
||||||
return rename(src.c_str(), target.c_str()) == 0;
|
return std::rename(src.c_str(), target.c_str()) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool file_exists(const std::string& file)
|
bool file_exists(const std::string& file)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user