From 3b2ea265547c4bff69b37268e50463c7f020b30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 4 Apr 2019 17:58:13 +0200 Subject: Fix segfault when audio system cannot be initialised `PyInit_aud()` can return `NULL` for variour reasons. When that happens, we shouldn't continue. --- intern/audaspace/intern/AUD_PyInit.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'intern/audaspace') diff --git a/intern/audaspace/intern/AUD_PyInit.cpp b/intern/audaspace/intern/AUD_PyInit.cpp index df020ed5427..b40cce34dfb 100644 --- a/intern/audaspace/intern/AUD_PyInit.cpp +++ b/intern/audaspace/intern/AUD_PyInit.cpp @@ -66,6 +66,11 @@ static PyMethodDef meth_sound_from_pointer[] = { PyObject *AUD_initPython(void) { PyObject *module = PyInit_aud(); + if (module == NULL) { + printf("Unable to initialise audio\n"); + return NULL; + } + PyModule_AddObject(module, "_sound_from_pointer", (PyObject *)PyCFunction_New(meth_sound_from_pointer, NULL)); PyDict_SetItemString(PyImport_GetModuleDict(), "aud", module); -- cgit v1.2.3