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);