summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Pool <mbp@samba.org>2002-11-05 02:54:07 +0000
committerMartin Pool <mbp@samba.org>2002-11-05 02:54:07 +0000
commitaf7ecaf61b009bff5de4d63863aaa39b006dbf81 (patch)
tree39b181699d5037a5bde65903a8965eb2d925458b
parent97d34f85c71acf52ea8ef5d04939eda0cbc47850 (diff)
downloadsamba-af7ecaf61b009bff5de4d63863aaa39b006dbf81.tar.gz
samba-af7ecaf61b009bff5de4d63863aaa39b006dbf81.tar.bz2
samba-af7ecaf61b009bff5de4d63863aaa39b006dbf81.zip
pytdbpack_pack_data: Oops, since B is separately encoded as buffer and
length we need separate counters traversing the format and value sequences to pack them. (This used to be commit 49a0ba46e6693bb819440d4ab40045afc4a7ae17)
-rw-r--r--source3/python/py_tdbpack.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/source3/python/py_tdbpack.c b/source3/python/py_tdbpack.c
index ba1e86384e..c68d6f8c57 100644
--- a/source3/python/py_tdbpack.c
+++ b/source3/python/py_tdbpack.c
@@ -600,14 +600,14 @@ pytdbpack_pack_data(const char *format_str,
PyObject *val_seq,
unsigned char *packed)
{
- int i;
+ int format_i, val_i = 0;
- for (i = 0; format_str[i]; i++) {
- char ch = format_str[i];
+ for (format_i = 0, val_i = 0; format_str[format_i]; format_i++) {
+ char ch = format_str[format_i];
PyObject *val_obj;
/* borrow a reference to the item */
- val_obj = PySequence_GetItem(val_seq, i);
+ val_obj = PySequence_GetItem(val_seq, val_i++);
if (!val_obj)
return NULL;
@@ -661,10 +661,13 @@ pytdbpack_pack_data(const char *format_str,
long size;
char *sval;
+ if (!PyInt_Check(val_obj))
+ return NULL;
+
size = PyInt_AsLong(val_obj);
pack_uint32(size, &packed);
- val_obj = PySequence_GetItem(val_seq, ++i);
+ val_obj = PySequence_GetItem(val_seq, val_i++);
if (!val_obj)
return NULL;