Apply a patch that fixes a bug and a memory leak.

Obtained from:	[ruby-dev:21973]
This commit is contained in:
Akinori MUSHA 2003-11-20 05:11:20 +00:00
parent 471191997e
commit de17ca25a4
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=94430
6 changed files with 249 additions and 0 deletions

View file

@ -7,6 +7,7 @@
PORTNAME= oniguruma
PORTVERSION= 1.9.5
PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= ${MASTER_SITE_RUBY}
MASTER_SITE_SUBDIR= contrib

View file

@ -0,0 +1,82 @@
Taken from: [ruby-dev:21973]
Index: regparse.c
===================================================================
--- regparse.c (.../ags/oniguruma/1.9.5) (revision 245)
+++ regparse.c (.../runk/oniguruma) (revision 245)
@@ -833,6 +833,10 @@
e->back_refs = (int* )NULL;
}
}
+ if (IS_NOT_NULL(t->e)) {
+ xfree(t->e);
+ t->e = NULL;
+ }
t->num = 0;
}
return 0;
@@ -3611,6 +3615,7 @@
enum CCVALTYPE val_type, in_type;
int val_israw, in_israw;
+ prev_cc = (CClassNode* )NULL;
*np = NULL_NODE;
r = fetch_token_in_cc(tok, src, end, env);
if (r == TK_BYTE && tok->u.c == '^') {
@@ -3633,7 +3638,6 @@
*np = node = node_new_cclass();
CHECK_NULL_RETURN_VAL(node, REGERR_MEMORY);
cc = &(NCCLASS(node));
- prev_cc = (CClassNode* )NULL;
and_start = 0;
state = CCS_START;
@@ -3810,6 +3814,7 @@
if (IS_NOT_NULL(prev_cc)) {
r = and_cclass(prev_cc, cc);
if (r != 0) goto err;
+ bbuf_free(cc->mbuf);
}
else {
prev_cc = cc;
@@ -3846,6 +3851,7 @@
if (IS_NOT_NULL(prev_cc)) {
r = and_cclass(prev_cc, cc);
if (r != 0) goto err;
+ bbuf_free(cc->mbuf);
cc = prev_cc;
}
@@ -3864,6 +3870,8 @@
return 0;
err:
+ if (cc != &(NCCLASS(*np)))
+ bbuf_free(cc->mbuf);
regex_node_free(*np);
return r;
}
@@ -4490,7 +4498,10 @@
*top = NULL;
r = parse_branch(&node, tok, term, src, end, env);
- if (r < 0) return r;
+ if (r < 0) {
+ regex_node_free(node);
+ return r;
+ }
if (r == term) {
*top = node;
Index: regcomp.c
===================================================================
--- regcomp.c (.../ags/oniguruma/1.9.5) (revision 245)
+++ regcomp.c (.../runk/oniguruma) (revision 245)
@@ -3675,6 +3675,7 @@
}
else {
len = mblen(code, *p);
+ if (i + len > OPT_EXACT_MAXLEN) break;
for (j = 0; j < len; j++)
to->s[i++] = *p++;
}

View file

@ -7,6 +7,7 @@
PORTNAME= oniguruma
PORTVERSION= 1.9.5
PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= ${MASTER_SITE_RUBY}
MASTER_SITE_SUBDIR= contrib

View file

@ -0,0 +1,82 @@
Taken from: [ruby-dev:21973]
Index: regparse.c
===================================================================
--- regparse.c (.../ags/oniguruma/1.9.5) (revision 245)
+++ regparse.c (.../runk/oniguruma) (revision 245)
@@ -833,6 +833,10 @@
e->back_refs = (int* )NULL;
}
}
+ if (IS_NOT_NULL(t->e)) {
+ xfree(t->e);
+ t->e = NULL;
+ }
t->num = 0;
}
return 0;
@@ -3611,6 +3615,7 @@
enum CCVALTYPE val_type, in_type;
int val_israw, in_israw;
+ prev_cc = (CClassNode* )NULL;
*np = NULL_NODE;
r = fetch_token_in_cc(tok, src, end, env);
if (r == TK_BYTE && tok->u.c == '^') {
@@ -3633,7 +3638,6 @@
*np = node = node_new_cclass();
CHECK_NULL_RETURN_VAL(node, REGERR_MEMORY);
cc = &(NCCLASS(node));
- prev_cc = (CClassNode* )NULL;
and_start = 0;
state = CCS_START;
@@ -3810,6 +3814,7 @@
if (IS_NOT_NULL(prev_cc)) {
r = and_cclass(prev_cc, cc);
if (r != 0) goto err;
+ bbuf_free(cc->mbuf);
}
else {
prev_cc = cc;
@@ -3846,6 +3851,7 @@
if (IS_NOT_NULL(prev_cc)) {
r = and_cclass(prev_cc, cc);
if (r != 0) goto err;
+ bbuf_free(cc->mbuf);
cc = prev_cc;
}
@@ -3864,6 +3870,8 @@
return 0;
err:
+ if (cc != &(NCCLASS(*np)))
+ bbuf_free(cc->mbuf);
regex_node_free(*np);
return r;
}
@@ -4490,7 +4498,10 @@
*top = NULL;
r = parse_branch(&node, tok, term, src, end, env);
- if (r < 0) return r;
+ if (r < 0) {
+ regex_node_free(node);
+ return r;
+ }
if (r == term) {
*top = node;
Index: regcomp.c
===================================================================
--- regcomp.c (.../ags/oniguruma/1.9.5) (revision 245)
+++ regcomp.c (.../runk/oniguruma) (revision 245)
@@ -3675,6 +3675,7 @@
}
else {
len = mblen(code, *p);
+ if (i + len > OPT_EXACT_MAXLEN) break;
for (j = 0; j < len; j++)
to->s[i++] = *p++;
}

View file

@ -7,6 +7,7 @@
PORTNAME= oniguruma
PORTVERSION= 1.9.5
PORTREVISION= 1
CATEGORIES= devel
MASTER_SITES= ${MASTER_SITE_RUBY}
MASTER_SITE_SUBDIR= contrib

View file

@ -0,0 +1,82 @@
Taken from: [ruby-dev:21973]
Index: regparse.c
===================================================================
--- regparse.c (.../ags/oniguruma/1.9.5) (revision 245)
+++ regparse.c (.../runk/oniguruma) (revision 245)
@@ -833,6 +833,10 @@
e->back_refs = (int* )NULL;
}
}
+ if (IS_NOT_NULL(t->e)) {
+ xfree(t->e);
+ t->e = NULL;
+ }
t->num = 0;
}
return 0;
@@ -3611,6 +3615,7 @@
enum CCVALTYPE val_type, in_type;
int val_israw, in_israw;
+ prev_cc = (CClassNode* )NULL;
*np = NULL_NODE;
r = fetch_token_in_cc(tok, src, end, env);
if (r == TK_BYTE && tok->u.c == '^') {
@@ -3633,7 +3638,6 @@
*np = node = node_new_cclass();
CHECK_NULL_RETURN_VAL(node, REGERR_MEMORY);
cc = &(NCCLASS(node));
- prev_cc = (CClassNode* )NULL;
and_start = 0;
state = CCS_START;
@@ -3810,6 +3814,7 @@
if (IS_NOT_NULL(prev_cc)) {
r = and_cclass(prev_cc, cc);
if (r != 0) goto err;
+ bbuf_free(cc->mbuf);
}
else {
prev_cc = cc;
@@ -3846,6 +3851,7 @@
if (IS_NOT_NULL(prev_cc)) {
r = and_cclass(prev_cc, cc);
if (r != 0) goto err;
+ bbuf_free(cc->mbuf);
cc = prev_cc;
}
@@ -3864,6 +3870,8 @@
return 0;
err:
+ if (cc != &(NCCLASS(*np)))
+ bbuf_free(cc->mbuf);
regex_node_free(*np);
return r;
}
@@ -4490,7 +4498,10 @@
*top = NULL;
r = parse_branch(&node, tok, term, src, end, env);
- if (r < 0) return r;
+ if (r < 0) {
+ regex_node_free(node);
+ return r;
+ }
if (r == term) {
*top = node;
Index: regcomp.c
===================================================================
--- regcomp.c (.../ags/oniguruma/1.9.5) (revision 245)
+++ regcomp.c (.../runk/oniguruma) (revision 245)
@@ -3675,6 +3675,7 @@
}
else {
len = mblen(code, *p);
+ if (i + len > OPT_EXACT_MAXLEN) break;
for (j = 0; j < len; j++)
to->s[i++] = *p++;
}