Issue 3307: invalid check of _bsddb creation failure (original) (raw)
newDBObject(), called by DB_construct(), doesn't check correctly the result of all to the external function db_create(). It checks if self->db is NULL, but db_create() doesn't change self->db value on error. So if self->db is uninitialized, the error is not catched.
Two ideas to fix the bug:
- check "if (err)" instead of "if (self->db != NULL)"
- set self->db=NULL before calling db_create()
I implemented the second proposition in the attached patch.
Note: The bug occurs with PYDEBUG, I don't know if PyObject_New() fills new allocate memory to zero (I think no, but I'm not sure).