From: Guido van Rossum Date: Mon, 2 Jun 2003 14:11:45 +0000 (+0000) Subject: Fix a subtle decref bug that caused a GC assertion to fail in a debug X-Git-Tag: v2.3c1~543 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f39dafb10a9c8b5d53c79f60ccf1bec77cc376a3;p=python Fix a subtle decref bug that caused a GC assertion to fail in a debug build (assert(gc->gc.gc_refs != 0) in visit_decref()). Because OSSAudioError is a global, we must compensate (twice!) for PyModule_AddObject()'s "helpful" decref of the object it adds. --- diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c index 40c328c334..c19f2e0b6f 100644 --- a/Modules/ossaudiodev.c +++ b/Modules/ossaudiodev.c @@ -938,6 +938,9 @@ initossaudiodev(void) OSSAudioError = PyErr_NewException("ossaudiodev.OSSAudioError", NULL, NULL); if (OSSAudioError) { + /* Each call to PyModule_AddObject decrefs it; compensate: */ + Py_INCREF(OSSAudioError); + Py_INCREF(OSSAudioError); PyModule_AddObject(m, "error", OSSAudioError); PyModule_AddObject(m, "OSSAudioError", OSSAudioError); }