-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-5013 Add NULL checks in InvalidDocument bson handling #2049
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
Changes from 1 commit
dc2cc10
005d942
7834214
fa60555
79a8c57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1747,6 +1747,9 @@ int write_dict(PyObject* self, buffer_t buffer, | |
| PyObject *etype = NULL, *evalue = NULL, *etrace = NULL; | ||
| PyErr_Fetch(&etype, &evalue, &etrace); | ||
| PyObject *InvalidDocument = _error("InvalidDocument"); | ||
| if (InvalidDocument == NULL) { | ||
| return 0; | ||
|
||
| } | ||
|
|
||
| if (top_level && InvalidDocument && PyErr_GivenExceptionMatches(etype, InvalidDocument)) { | ||
|
|
||
|
|
@@ -1760,6 +1763,9 @@ int write_dict(PyObject* self, buffer_t buffer, | |
| if (msg) { | ||
| // Prepend doc to the existing message | ||
| PyObject *dict_str = PyObject_Str(dict); | ||
| if (dict_str == NULL) { | ||
| return 0; | ||
|
||
| } | ||
| PyObject *new_msg = PyUnicode_FromFormat("Invalid document %s | %s", PyUnicode_AsUTF8(dict_str), PyUnicode_AsUTF8(msg)); | ||
|
||
| Py_DECREF(dict_str); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized there's a larger problem here. This logic is only in place for the
is_dictfast path where it should be added generically for any mapping.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll see if I can factor this out.