From fc93f75da75e430a20b37f2a73dacfa94d8a9758 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Tue, 17 Dec 1996 00:47:03 +0000 Subject: [PATCH] Better error checking in initmath(). --- Modules/mathmodule.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 6e2d65bd023..b993bfcb426 100644 --- a/Modules/mathmodule.c +++ b/Modules/mathmodule.c @@ -242,8 +242,19 @@ initmath() m = Py_InitModule("math", math_methods); d = PyModule_GetDict(m); - PyDict_SetItemString(d, "pi", v = PyFloat_FromDouble(atan(1.0) * 4.0)); + + if (!(v = PyFloat_FromDouble(atan(1.0) * 4.0))) + goto finally; + if (PyDict_SetItemString(d, "pi", v) < 0) + goto finally; Py_DECREF(v); - PyDict_SetItemString(d, "e", v = PyFloat_FromDouble(exp(1.0))); + + if (!(v = PyFloat_FromDouble(exp(1.0)))) + goto finally; + if (PyDict_SetItemString(d, "e", ) < 0) + goto finally; Py_DECREF(v); + + finally: + Py_FatalError("can't initialize math module"); }