[New-bugs-announce] [issue5627] PyDict_SetItemString() fails when the second argument is null

Euler Taveira de Oliveira report at bugs.python.org
Tue Mar 31 18:47:13 CEST 2009


New submission from Euler Taveira de Oliveira <euler at timbira.com>:

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 <report at bugs.python.org>
<http://bugs.python.org/issue5627>
_______________________________________


More information about the New-bugs-announce mailing list