Ver Fonte

Resolves: bug 501490 - Error creating view on FDS 1.2
Reviewed by: nhosoi (Thanks!)
The problem is when the views code calls views_cache_discover_children()
and there are no children. The code should check to see if the child_count
is 0, and only attempt to alloc space for the pChildren array if the
child_count is greater than 0.
Platforms tested: RHEL5 x86_64

Rich Megginson há 16 anos atrás
pai
commit
f2ad3fd08e
1 ficheiros alterados com 10 adições e 7 exclusões
  1. 10 7
      ldap/servers/plugins/views/views.c

+ 10 - 7
ldap/servers/plugins/views/views.c

@@ -703,16 +703,19 @@ static void views_cache_discover_children(viewEntry *pView)
 
 	/* make the space for them */
 	pView->child_count = child_count;
-	
-	pView->pChildren = (void **)slapi_ch_calloc(child_count, sizeof(viewEntry*));
 
-	/* add them */
-	for(current = head; current != NULL; current = current->list.pNext)
+	if (child_count > 0)
 	{
-		if(slapi_dn_isparent(pView->pDn, current->pDn))
+		pView->pChildren = (void **)slapi_ch_calloc(child_count, sizeof(viewEntry*));
+
+		/* add them */
+		for(current = head; current != NULL; current = current->list.pNext)
 		{
-			((viewEntry**)pView->pChildren)[add_count] = current;
-			add_count++;
+			if(slapi_dn_isparent(pView->pDn, current->pDn))
+			{
+				((viewEntry**)pView->pChildren)[add_count] = current;
+				add_count++;
+			}
 		}
 	}
 }