8000 gh-104698: Fix reference leak in mmapmodule.c by Eclips4 · Pull Request #104700 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-104698: Fix reference leak in mmapmodule.c #104700

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename macro
  • Loading branch information
Eclips4 committed May 20, 2023
commit 42a4cb1591107735ac28f8c1068aa7e1129324d7
10 changes: 5 additions & 5 deletions Modules/mmapmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ do { \
return err; \
} \
} while (0)
#define CHECK_VALID_AND_RELEASE(err, buffer) \
#define CHECK_VALID_OR_RELEASE(err, buffer) \
do { \
if (self->map_handle == NULL) { \
PyErr_SetString(PyExc_ValueError, "mmap closed or invalid"); \
Expand All @@ -245,7 +245,7 @@ do { \
return err; \
} \
} while (0)
#define CHECK_VALID_AND_RELEASE(err, buffer) \
#define CHECK_VALID_OR_RELEASE(err, buffer) \
do { \
if (self->data == NULL) { \
PyErr_SetString(PyExc_ValueError, "mmap closed or invalid"); \
Expand Down Expand Up @@ -342,7 +342,7 @@ mmap_gfind(mmap_object *self,
end = self->size;

Py_ssize_t res;
CHECK_VALID_AND_RELEASE(NULL, view);
CHECK_VALID_OR_RELEASE(NULL, view);
if (reverse) {
res = _PyBytes_ReverseFind(
self->data + start, end - start,
Expand Down Expand Up @@ -419,7 +419,7 @@ mmap_write_method(mmap_object *self,
return NULL;
}

CHECK_VALID_AND_RELEASE(NULL, data);
CHECK_VALID_OR_RELEASE(NULL, data);
memcpy(&self->data[self->pos], data.buf, data.len);
self->pos += data.len;
PyBuffer_Release(&data);
Expand Down Expand Up @@ -1103,7 +1103,7 @@ mmap_ass_subscript(mmap_object *self, PyObject *item, PyObject *value)
return -1;
}

CHECK_VALID_AND_RELEASE(-1, vbuf);
CHECK_VALID_OR_RELEASE(-1, vbuf);
if (slicelen == 0) {
}
else if (step == 1) {
Expand Down
0