Check types of dictionary elements in to_struct()
authorTim Potter <tpot@samba.org>
Mon, 27 May 2002 06:33:33 +0000 (06:33 +0000)
committerTim Potter <tpot@samba.org>
Mon, 27 May 2002 06:33:33 +0000 (06:33 +0000)
source/python/py_conv.c

index 9093b54b00f7676ad0d2536d042707c10d42c884..39b20ace8612a952cbb88b363b6dd20d98bd6b07 100644 (file)
@@ -99,9 +99,10 @@ BOOL to_struct(void *s, PyObject *dict, struct pyconv *conv)
                        UNISTR *u = (UNISTR *)((char *)s + conv[i].offset);
                        char *s = "";
 
-                       if (obj && PyString_Check(obj))
-                               s = PyString_AsString(obj);
+                       if (!PyString_Check(obj))
+                               goto done;
 
+                       s = PyString_AsString(obj);
                        init_unistr(u, s);
                        
                        break;
@@ -109,21 +110,20 @@ BOOL to_struct(void *s, PyObject *dict, struct pyconv *conv)
                case PY_UINT32: {
                        uint32 *u = (uint32 *)((char *)s + conv[i].offset);
 
-                       if (obj && PyInt_Check(obj)) 
-                               *u = PyInt_AsLong(obj);
-                       else
-                               *u = 0;
+                       if (!PyInt_Check(obj))
+                               goto done;
+
+                       *u = PyInt_AsLong(obj);
 
                        break;
                }
                case PY_UINT16: {
                        uint16 *u = (uint16 *)((char *)s + conv[i].offset);
 
-                       if (obj && PyInt_Check(obj)) 
-                               *u = PyInt_AsLong(obj);
-                       else
-                               *u = 0;
+                       if (!PyInt_Check(obj)) 
+                               goto done;
 
+                       *u = PyInt_AsLong(obj);
                        break;
                }
                default: