浏览代码

Bug 610119 - fix coverify Defect Type: Null pointer dereferences issues 12167 - 12199

https://bugzilla.redhat.com/show_bug.cgi?id=610119
Resolves: bug 610119
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 12167 - 12199
Fix description: Catch possible NULL pointer in index_range_read().
Noriko Hosoi 15 年之前
父节点
当前提交
2daecd99e1
共有 1 个文件被更改,包括 17 次插入14 次删除
  1. 17 14
      ldap/servers/slapd/back-ldbm/index.c

+ 17 - 14
ldap/servers/slapd/back-ldbm/index.c

@@ -1135,6 +1135,13 @@ index_range_read(
     int sizelimit = 0;
     time_t curtime, stoptime, optime;
     int timelimit = -1;
+    back_search_result_set *sr = NULL;
+
+    if (!pb) {
+        LDAPDebug(LDAP_DEBUG_ANY, "index_range_read: NULL pblock\n",
+                  0, 0, 0);
+        return NULL;
+    }
 
     *err = 0;
 
@@ -1156,22 +1163,18 @@ index_range_read(
 
     /*
      * Determine the lookthrough_limit from the PBlock.
-     * No limit if there is no PBlock supplied or if there is no
-     * search result set and the requestor is root.
+     * No limit if there is no search result set and the requestor is root.
      */
-    if (pb != NULL) {
-        back_search_result_set *sr = NULL;
 
-        slapi_pblock_get( pb, SLAPI_SEARCH_RESULT_SET, &sr );
-        if (sr != NULL) {
-            /* the normal case */
-            lookthrough_limit = sr->sr_lookthroughlimit;
-        } else {
-            int isroot = 0;
-            slapi_pblock_get( pb, SLAPI_REQUESTOR_ISROOT, &isroot );
-            if (!isroot) {
-                lookthrough_limit = li->li_lookthroughlimit; 
-            }
+    slapi_pblock_get( pb, SLAPI_SEARCH_RESULT_SET, &sr );
+    if (sr != NULL) {
+        /* the normal case */
+        lookthrough_limit = sr->sr_lookthroughlimit;
+    } else {
+        int isroot = 0;
+        slapi_pblock_get( pb, SLAPI_REQUESTOR_ISROOT, &isroot );
+        if (!isroot) {
+            lookthrough_limit = li->li_lookthroughlimit; 
         }
     }