
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2008-07-03 17:54 bystutzbach, last changed2022-04-11 14:56 byadmin. This issue is nowclosed.
| Messages (4) | |||
|---|---|---|---|
| msg69213 -(view) | Author: Daniel Stutzbach (stutzbach)![]() | Date: 2008-07-03 17:54 | |
I'm writing a C extension module and discovered that Py_CLEAR() causes acrash if the programmer happened to name their variable "tmp". ThePy_CLEAR() macro internally uses the name "tmp" in a new scope, hidingthe callers "tmp", and calling Py_DECREF() on an essentially random bitof memory.I suggest changing Py_CLEAR() to use something a little less common than"tmp". Perhaps "_py_tmp".For easy reference, here's how Py_CLEAR() is defined now:#define Py_CLEAR(op)\ do { \ if (op) {\ PyObject *tmp = (PyObject *)(op);\ (op) = NULL;\ Py_DECREF(tmp);\ }\ } while (0) | |||
| msg69498 -(view) | Author: Alyssa Coghlan (ncoghlan)*![]() | Date: 2008-07-10 10:11 | |
A better option may be to append _tmp to the passed in token:#define Py_CLEAR(op)\ do { \ if (op) {\ PyObject *op##_tmp = (PyObject *)(op);\ (op) = NULL;\ Py_DECREF(op##_tmp);\ }\ } while (0) | |||
| msg69500 -(view) | Author: Daniel Stutzbach (stutzbach)![]() | Date: 2008-07-10 12:24 | |
Appending _tmp is a good idea, but it won't work when the parameterisn't a simple symbol. For example, there's a line in cPickle.c likethis: Py_CLEAR(*p). | |||
| msg69621 -(view) | Author: Alexandre Vassalotti (alexandre.vassalotti)*![]() | Date: 2008-07-13 20:43 | |
Committed the fixr64927. Thanks. | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:36 | admin | set | github: 47524 |
| 2008-07-13 20:43:46 | alexandre.vassalotti | set | status: open -> closed resolution: fixed messages: +msg69621 nosy: +alexandre.vassalotti |
| 2008-07-10 12:24:55 | stutzbach | set | messages: +msg69500 |
| 2008-07-10 10:11:07 | ncoghlan | set | nosy: +ncoghlan messages: +msg69498 |
| 2008-07-03 17:54:08 | stutzbach | create | |