Issue5627
Created on 2009-03-31 16:47 by eulerto, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Messages (7) | |||
|---|---|---|---|
| msg84833 - (view) | Author: Euler Taveira de Oliveira (eulerto) | Date: 2009-03-31 16:47 | |
PyDict_SetItemString() fails when the second argument (key) is null pointer. It occurs because PyString_FromString(key) call doesn't check for null pointer and if we're in a disabled assert environment the assert() is not caught and strlen() fails. I don't know what is the best fix but we have two possibilities: (i) check the second argument in PyDict_SetItemString() before calling PyString_FromString() and returns null if that argument is null; (ii) replace the assert() in PyString_FromString() to 'if (str == NULL) return NULL;'. This bug was reported as a PostgreSQL bug at [1]. [1] http://archives.postgresql.org/pgsql-hackers/2009-03/msg01344.php |
|||
| msg84851 - (view) | Author: Euler Taveira de Oliveira (eulerto) | Date: 2009-03-31 18:20 | |
It seems PyDict_DelItemString() and PyDict_SetItem() suffer from the same disease. :( Both use assert() to detect a null pointer but fail to prevent it. As I stated in the previous comment, maybe the right fix is to replace assert() with the 'if (foo == NULL) return whatever'. |
|||
| msg84978 - (view) | Author: Georg Brandl (georg.brandl) * | Date: 2009-04-01 04:30 | |
I am not sure why you consider this a bug. You should certainly not pass NULL pointers around where the docs do not explicitly allow this. |
|||
| msg84983 - (view) | Author: Euler Taveira de Oliveira (eulerto) | Date: 2009-04-01 05:33 | |
I know that it is a good programming practice checking null pointers but sometimes programmers are lazy. ;) I still think that high level functions should check for null pointers. |
|||
| msg85114 - (view) | Author: Georg Brandl (georg.brandl) * | Date: 2009-04-01 23:12 | |
Raymond, do you have an opinion about this? |
|||
| msg85142 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2009-04-02 02:46 | |
I recommend rejecting this one. The assert is sufficient for third-party modules to run their tests and detect bad calls. The code path is too critical to add another check. |
|||
| msg85145 - (view) | Author: Georg Brandl (georg.brandl) * | Date: 2009-04-02 02:52 | |
Closing. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:47 | admin | set | github: 49877 |
| 2009-04-02 02:52:51 | georg.brandl | set | status: open -> closed messages: + msg85145 |
| 2009-04-02 02:46:14 | rhettinger | set | assignee: loewis -> georg.brandl messages: + msg85142 |
| 2009-04-02 02:44:40 | rhettinger | set | messages: - msg85138 |
| 2009-04-02 02:44:32 | rhettinger | set | messages: - msg85134 |
| 2009-04-02 02:29:36 | loewis | set | messages:
+ msg85138 title: PyDict_SetItemString() fails when the second argument is null -> PyDict_SetItemString() fails when the second argument is null |
| 2009-04-02 01:46:45 | rhettinger | set | status: pending -> open nosy:
+ loewis assignee: rhettinger -> loewis |
| 2009-04-01 23:12:39 | georg.brandl | set | assignee: rhettinger messages:
+ msg85114 |
| 2009-04-01 05:33:13 | eulerto | set | messages: + msg84983 |
| 2009-04-01 04:30:56 | georg.brandl | set | status: open -> pending nosy:
+ georg.brandl resolution: wont fix |
| 2009-03-31 18:20:38 | eulerto | set | messages: + msg84851 |
| 2009-03-31 16:47:12 | eulerto | create | |