From 0699490e5adc3a82c2f649ad50ffdda4881d689c Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Thu, 31 Jan 2013 10:44:39 -0500 Subject: [PATCH] Don't dereference a null pointer --- .../Plasma/FeatureLib/pfPython/pyPlayerGlue.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfPython/pyPlayerGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyPlayerGlue.cpp index 3c5ab334..e6719eba 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyPlayerGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyPlayerGlue.cpp @@ -67,26 +67,21 @@ PYTHON_INIT_DEFINITION(ptPlayer, args, keywords) PYTHON_RETURN_INIT_ERROR; } - pyKey* key = NULL; + plKey key; plString name; uint32_t pid = -1; float distSeq = -1; if (pyKey::Check(firstObj)) { - key = pyKey::ConvertFrom(firstObj); - if (!PyString_CheckEx(secondObj)) - { - PyErr_SetString(PyExc_TypeError, "__init__ expects one of two argument lists: (ptKey, string, unsigned long, float) or (string, unsigned long)"); - PYTHON_RETURN_INIT_ERROR; - } else - name = PyString_AsStringEx(secondObj); - if (!(PyNumber_Check(thirdObj) && PyFloat_Check(fourthObj))) + if (!(PyString_CheckEx(secondObj) && PyNumber_Check(thirdObj) && PyFloat_Check(fourthObj))) { PyErr_SetString(PyExc_TypeError, "__init__ expects one of two argument lists: (ptKey, string, unsigned long, float) or (string, unsigned long)"); PYTHON_RETURN_INIT_ERROR; } + key = pyKey::ConvertFrom(firstObj)->getKey(); + name = PyString_AsStringEx(secondObj); pid = PyNumber_AsSsize_t(thirdObj, NULL); distSeq = (float)PyFloat_AsDouble(fourthObj); } else if (PyString_CheckEx(firstObj)) { @@ -103,7 +98,7 @@ PYTHON_INIT_DEFINITION(ptPlayer, args, keywords) PYTHON_RETURN_INIT_ERROR; } - self->fThis->Init(key->getKey(), name.c_str(), pid, distSeq); + self->fThis->Init(key, name.c_str(), pid, distSeq); PYTHON_RETURN_INIT_OK; }