[issue5627] PyDict_SetItemString() fails when the second argument is null

2009-03-31 Thread Euler Taveira de Oliveira

New submission from Euler Taveira de Oliveira :

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

--
components: Interpreter Core
messages: 84833
nosy: eulerto
severity: normal
status: open
title: PyDict_SetItemString() fails when the second argument is null
type: crash

___
Python tracker 
<http://bugs.python.org/issue5627>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5627] PyDict_SetItemString() fails when the second argument is null

2009-03-31 Thread Euler Taveira de Oliveira

Euler Taveira de Oliveira  added the comment:

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'.

--

___
Python tracker 
<http://bugs.python.org/issue5627>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5627] PyDict_SetItemString() fails when the second argument is null

2009-03-31 Thread Euler Taveira de Oliveira

Euler Taveira de Oliveira  added the comment:

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.

--

___
Python tracker 
<http://bugs.python.org/issue5627>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com