svn commit: samba r16880 - in branches/SOC/mkhl/ldb-map/modules: .

mkhl at samba.org mkhl at samba.org
Sat Jul 8 17:37:13 GMT 2006


Author: mkhl
Date: 2006-07-08 17:37:13 +0000 (Sat, 08 Jul 2006)
New Revision: 16880

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16880

Log:

Fix assignment of mapped subtrees to wrong places.

Martin

Modified:
   branches/SOC/mkhl/ldb-map/modules/ldb_map.c


Changeset:
Modified: branches/SOC/mkhl/ldb-map/modules/ldb_map.c
===================================================================
--- branches/SOC/mkhl/ldb-map/modules/ldb_map.c	2006-07-08 17:33:19 UTC (rev 16879)
+++ branches/SOC/mkhl/ldb-map/modules/ldb_map.c	2006-07-08 17:37:13 UTC (rev 16880)
@@ -1094,7 +1094,7 @@
 		       struct ldb_parse_tree **new,
 		       const struct ldb_parse_tree *tree)
 {
-	int i, ret;
+	int i, j, ret;
 
 	/* prepare new tree */
 	*new = talloc_memdup(mem_ctx, tree, sizeof(struct ldb_parse_tree));
@@ -1113,6 +1113,7 @@
 	}
 
 	/* generate list of local subtrees */
+	j = 0;
 	for (i = 0; i < tree->u.list.num_elements; i++) {
 		struct ldb_parse_tree *child;
 		ret = keep_local_subtree(module, *new, &child,
@@ -1121,16 +1122,17 @@
 			goto failed;
 
 		if (child) {
-			(*new)->u.list.elements[i] = child;
-			(*new)->u.list.num_elements++;
+			(*new)->u.list.elements[j] = child;
+			j++;
 		}
 	}
 
 	/* prune tree without subtrees */
-	if ((*new)->u.list.num_elements == 0)
+	if (j == 0)
 		goto prune;
 
 	/* fix subtree list size */
+	(*new)->u.list.num_elements = j;
 	(*new)->u.list.elements = talloc_realloc(*new, (*new)->u.list.elements,
 						 struct ldb_parse_tree *,
 						 (*new)->u.list.num_elements);
@@ -1266,7 +1268,7 @@
 		       struct ldb_parse_tree **new,
 		       const struct ldb_parse_tree *tree)
 {
-	int i, ret;
+	int i, j, ret;
 
 	/* prepare new tree */
 	*new = talloc_memdup(mem_ctx, tree, sizeof(struct ldb_parse_tree));
@@ -1285,6 +1287,7 @@
 	}
 
 	/* generate list of remote subtrees */
+	j = 0;
 	for (i = 0; i < tree->u.list.num_elements; i++) {
 		struct ldb_parse_tree *child;
 		ret = map_local_subtree(module, *new, &child,
@@ -1293,16 +1296,17 @@
 			goto failed;
 
 		if (child) {
-			(*new)->u.list.elements[i] = child;
-			(*new)->u.list.num_elements++;
+			(*new)->u.list.elements[j] = child;
+			j++;
 		}
 	}
 
 	/* prune tree without subtrees */
-	if ((*new)->u.list.num_elements == 0)
+	if (j == 0)
 		goto prune;
 
 	/* fix subtree list size */
+	(*new)->u.list.num_elements = j;
 	(*new)->u.list.elements = talloc_realloc(*new, (*new)->u.list.elements,
 						 struct ldb_parse_tree *,
 						 (*new)->u.list.num_elements);



More information about the samba-cvs mailing list