summaryrefslogtreecommitdiffstats
path: root/onig-6.9.9-fix-memleaks-initialize-memory.patch
blob: 7c7fb1629e68caf586e6e9214a87c651463957ab (plain)
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
38
diff -up onig-6.9.9/src/regexec.c.orig onig-6.9.9/src/regexec.c
--- onig-6.9.9/src/regexec.c.orig	2022-12-12 14:27:04.000000000 +0100
+++ onig-6.9.9/src/regexec.c	2024-07-29 12:30:55.752328341 +0200
@@ -4517,6 +4517,7 @@ regset_search_body_position_lead(OnigReg
 
   sr = (SearchRange* )xmalloc(sizeof(*sr) * n);
   CHECK_NULL_RETURN_MEMERR(sr);
+  xmemset(sr, 0, sizeof(*sr) * n);
 
   for (i = 0; i < n; i++) {
     reg = set->rs[i].reg;
diff -up onig-6.9.9/src/regparse.c.orig onig-6.9.9/src/regparse.c
--- onig-6.9.9/src/regparse.c.orig	2024-07-29 12:31:07.838347726 +0200
+++ onig-6.9.9/src/regparse.c	2024-07-29 12:33:48.509582274 +0200
@@ -4190,7 +4190,10 @@ and_cclass(CClassNode* dest, CClassNode*
         pbuf = tbuf;
       }
     }
-    if (r != 0) return r;
+    if (r != 0) {
+        bbuf_free(pbuf);
+        return r;
+    }
 
     dest->mbuf = pbuf;
     bbuf_free(buf1);
@@ -4247,7 +4250,10 @@ or_cclass(CClassNode* dest, CClassNode*
         pbuf = tbuf;
       }
     }
-    if (r != 0) return r;
+    if (r != 0) {
+        bbuf_free(pbuf);
+        return r;
+    }
 
     dest->mbuf = pbuf;
     bbuf_free(buf1);