From e9f909aa25dda4491ac25400dd12732fcc4626b8 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Sat, 17 Aug 2024 10:01:25 +1200 Subject: [PATCH] minisat: Record changes in patch --- libs/minisat/00_PATCH_warnings.patch | 37 ++++++++++++++++++++++++++++ libs/minisat/00_UPDATE.sh | 1 + 2 files changed, 38 insertions(+) create mode 100644 libs/minisat/00_PATCH_warnings.patch diff --git a/libs/minisat/00_PATCH_warnings.patch b/libs/minisat/00_PATCH_warnings.patch new file mode 100644 index 000000000..e543b1046 --- /dev/null +++ b/libs/minisat/00_PATCH_warnings.patch @@ -0,0 +1,37 @@ +--- System.cc ++++ System.cc +@@ -43,7 +43,7 @@ static inline int memReadStat(int field) + pid_t pid = getpid(); + int value; + +- sprintf(name, "/proc/%d/statm", pid); ++ snprintf(name, 256, "/proc/%d/statm", pid); + FILE* in = fopen(name, "rb"); + if (in == NULL) return 0; + +@@ -60,7 +60,7 @@ static inline int memReadPeak(void) + char name[256]; + pid_t pid = getpid(); + +- sprintf(name, "/proc/%d/status", pid); ++ snprintf(name, 256, "/proc/%d/status", pid); + FILE* in = fopen(name, "rb"); + if (in == NULL) return 0; + +--- Vec.h ++++ Vec.h +@@ -100,7 +100,13 @@ void vec::capacity(Size min_cap) { + Size add = max((min_cap - cap + 1) & ~1, ((cap >> 1) + 2) & ~1); // NOTE: grow by approximately 3/2 + const Size size_max = std::numeric_limits::max(); + if ( ((size_max <= std::numeric_limits::max()) && (add > size_max - cap)) +- || (((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL) && errno == ENOMEM) ) ++ || ( ++#ifdef _DEFAULT_SOURCE ++ ((data = (T*)::reallocarray(data, (cap += add), sizeof(T))) == NULL) ++#else ++ ((data = (T*)::realloc(data, (cap += add) * sizeof(T))) == NULL) ++#endif ++ && errno == ENOMEM) ) + throw OutOfMemoryException(); + } + diff --git a/libs/minisat/00_UPDATE.sh b/libs/minisat/00_UPDATE.sh index 51107e450..6f3eadfe7 100755 --- a/libs/minisat/00_UPDATE.sh +++ b/libs/minisat/00_UPDATE.sh @@ -17,3 +17,4 @@ patch -p0 < 00_PATCH_remove_zlib.patch patch -p0 < 00_PATCH_no_fpu_control.patch patch -p0 < 00_PATCH_typofixes.patch patch -p0 < 00_PATCH_wasm.patch +patch -p0 < 00_PATCH_warnings.patch