File: 00_PATCH_warnings.patch

package info (click to toggle)
yosys 0.52-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 69,796 kB
  • sloc: ansic: 696,955; cpp: 239,736; python: 14,617; yacc: 3,529; sh: 2,175; makefile: 1,945; lex: 697; perl: 445; javascript: 323; tcl: 162; vhdl: 115
file content (37 lines) | stat: -rw-r--r-- 1,277 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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<T,_Size>::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<Size>::max();
     if ( ((size_max <= std::numeric_limits<int>::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();
  }