mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
Check types of dictionary elements in to_struct()
(This used to be commit 793f1042f1
)
This commit is contained in:
@ -99,9 +99,10 @@ BOOL to_struct(void *s, PyObject *dict, struct pyconv *conv)
|
|||||||
UNISTR *u = (UNISTR *)((char *)s + conv[i].offset);
|
UNISTR *u = (UNISTR *)((char *)s + conv[i].offset);
|
||||||
char *s = "";
|
char *s = "";
|
||||||
|
|
||||||
if (obj && PyString_Check(obj))
|
if (!PyString_Check(obj))
|
||||||
s = PyString_AsString(obj);
|
goto done;
|
||||||
|
|
||||||
|
s = PyString_AsString(obj);
|
||||||
init_unistr(u, s);
|
init_unistr(u, s);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -109,21 +110,20 @@ BOOL to_struct(void *s, PyObject *dict, struct pyconv *conv)
|
|||||||
case PY_UINT32: {
|
case PY_UINT32: {
|
||||||
uint32 *u = (uint32 *)((char *)s + conv[i].offset);
|
uint32 *u = (uint32 *)((char *)s + conv[i].offset);
|
||||||
|
|
||||||
if (obj && PyInt_Check(obj))
|
if (!PyInt_Check(obj))
|
||||||
*u = PyInt_AsLong(obj);
|
goto done;
|
||||||
else
|
|
||||||
*u = 0;
|
*u = PyInt_AsLong(obj);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PY_UINT16: {
|
case PY_UINT16: {
|
||||||
uint16 *u = (uint16 *)((char *)s + conv[i].offset);
|
uint16 *u = (uint16 *)((char *)s + conv[i].offset);
|
||||||
|
|
||||||
if (obj && PyInt_Check(obj))
|
if (!PyInt_Check(obj))
|
||||||
*u = PyInt_AsLong(obj);
|
goto done;
|
||||||
else
|
|
||||||
*u = 0;
|
|
||||||
|
|
||||||
|
*u = PyInt_AsLong(obj);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user