瀏覽代碼

Bug 613056 - fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939

https://bugzilla.redhat.com/show_bug.cgi?id=613056
Resolves: bug 613056
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
description: Catch possible NULL pointer in mapping_tree_entry_modify_callback() and mtn_remove_node().
Endi S. Dewata 15 年之前
父節點
當前提交
9e6ba5ad02
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      ldap/servers/slapd/mapping_tree.c

+ 4 - 4
ldap/servers/slapd/mapping_tree.c

@@ -1375,7 +1375,7 @@ int mapping_tree_entry_modify_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefor
 
 
 int mapping_tree_entry_add_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg) 
 int mapping_tree_entry_add_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg) 
 {
 {
-    mapping_tree_node *node;
+    mapping_tree_node *node = NULL;
     int i;
     int i;
     backend * be;
     backend * be;
 
 
@@ -1387,12 +1387,12 @@ int mapping_tree_entry_add_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore,
      * be checked again 
      * be checked again 
      */
      */
     *returncode = mapping_tree_entry_add(entryBefore, &node);
     *returncode = mapping_tree_entry_add(entryBefore, &node);
-    if (LDAP_SUCCESS != *returncode)
+    if (LDAP_SUCCESS != *returncode || !node)
     {
     {
         return SLAPI_DSE_CALLBACK_ERROR;
         return SLAPI_DSE_CALLBACK_ERROR;
     }
     }
 
 
-    if(node && node->mtn_parent != NULL && node != mapping_tree_root )
+    if(node->mtn_parent != NULL && node != mapping_tree_root )
     {
     {
      /* If the node has a parent and the node is not the mapping tree root,
      /* If the node has a parent and the node is not the mapping tree root,
       * then add it as a child node. Note that the special case when the
       * then add it as a child node. Note that the special case when the
@@ -1433,7 +1433,7 @@ static void mtn_remove_node(mapping_tree_node * node)
 
 
         PR_ASSERT(tmp_node != NULL);
         PR_ASSERT(tmp_node != NULL);
 
 
-        tmp_node->mtn_brother = node->mtn_brother;
+        if (tmp_node) tmp_node->mtn_brother = node->mtn_brother;
     }
     }
     node->mtn_brother = NULL;
     node->mtn_brother = NULL;
 }
 }