From fe4e406114752c7d61280f32b4af84cdc2504b4d Mon Sep 17 00:00:00 2001 From: nima Date: Sat, 20 Dec 2008 15:49:18 +0000 Subject: Handle cases where user asks for invalid types. Updated test cases to test for this too. git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@136 abc39116-655e-4be6-ad55-d661dc543056 --- src/dmidecodemodule.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/dmidecodemodule.c b/src/dmidecodemodule.c index 03001a8..3030b97 100644 --- a/src/dmidecodemodule.c +++ b/src/dmidecodemodule.c @@ -192,9 +192,12 @@ static PyObject* dmidecode_get_slot(PyObject *self, PyObject *args) { retur static PyObject* dmidecode_get_type(PyObject *self, PyObject *args) { long unsigned int lu; if(PyArg_ParseTuple(args, (char *)"i", &lu)) { - char s[8]; - sprintf(s, "%lu", lu); - return dmidecode_get(self, s); + if(lu < 256) { + char s[8]; + sprintf(s, "%lu", lu); + return dmidecode_get(self, s); + } + return Py_False; } return Py_None; } -- cgit