Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-133546: Makere.Match
a well-roundedSequence
type#133549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
74480a7
a3de846
603b1d1
70b73e4
f51ef45
f218828
5272141
d0aa6fa
5f67be0
17feaa6
fe709f8
4095b52
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2657,8 +2657,9 @@ _sre_SRE_Match_index_impl(MatchObject *self, PyObject *value, | ||
if (start < 0) { | ||
start += self->groups; | ||
if (start < 0) { | ||
start = 0; | ||
} | ||
} | ||
if (stop < 0) { | ||
stop += self->groups; | ||
@@ -2668,14 +2669,17 @@ _sre_SRE_Match_index_impl(MatchObject *self, PyObject *value, | ||
} | ||
for (i = start; i < stop; i++) { | ||
PyObject* group = match_getslice_by_index(self, i, Py_None); | ||
if (group == NULL) { | ||
return NULL; | ||
} | ||
int cmp = PyObject_RichCompareBool(group, value, Py_EQ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I'm pretty sure we need to incref the value in case the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Not sure if this is what you're talking about, but I think this is already handled by Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It's not about the returned object, it's about the inputs. In order to determine whether there is a UAF or not, you need to check whether There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I see, thanks for the explanation! | ||
Py_DECREF(group); | ||
if (cmp > 0) { | ||
return PyLong_FromSsize_t(i); | ||
} | ||
else if (cmp < 0) { | ||
return NULL; | ||
} | ||
} | ||
PyErr_SetString(PyExc_ValueError, "match.index(x): x not in match"); | ||
picnixz marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
return NULL; | ||
@@ -2699,14 +2703,17 @@ _sre_SRE_Match_count_impl(MatchObject *self, PyObject *value) | ||
for (i = 0; i < self->groups; i++) { | ||
PyObject* group = match_getslice_by_index(self, i, Py_None); | ||
if (group == NULL) { | ||
return NULL; | ||
} | ||
int cmp = PyObject_RichCompareBool(group, value, Py_EQ); | ||
Py_DECREF(group); | ||
if (cmp > 0) { | ||
picnixz marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Now you can use an | ||
count++; | ||
} | ||
else if (cmp < 0) { | ||
return NULL; | ||
} | ||
} | ||
return PyLong_FromSsize_t(count); | ||
} | ||
Uh oh!
There was an error while loading.Please reload this page.