]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
check return value before using key_values
authorAndrej Gessel <Andrej.Gessel@janztec.com>
Tue, 19 Jun 2018 08:07:51 +0000 (10:07 +0200)
committerJeremy Allison <jra@samba.org>
Sat, 23 Jun 2018 00:00:28 +0000 (02:00 +0200)
there are also mem leaks in this function

Signed-off-by: Andrej Gessel <Andrej.Gessel@janztec.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/ldb/ldb_tdb/ldb_index.c

index 9ef786f3a9b1f81ad6125e809bbb8e0ee1d066f8..fb606124fb41d68b22fd57c9f018869ec8db76b8 100644 (file)
@@ -1765,13 +1765,14 @@ static int ltdb_index_filter(struct ltdb_private *ltdb,
                                          struct guid_tdb_key,
                                          dn_list->count);
 
+               if (key_values == NULL) {
+                       talloc_free(keys);
+                       return ldb_module_oom(ac->module);
+               }
                for (i = 0; i < dn_list->count; i++) {
                        keys[i].dptr = key_values[i].guid_key;
                        keys[i].dsize = sizeof(key_values[i].guid_key);
                }
-               if (key_values == NULL) {
-                       return ldb_module_oom(ac->module);
-               }
        } else {
                for (i = 0; i < dn_list->count; i++) {
                        keys[i].dptr = NULL;
@@ -1788,6 +1789,7 @@ static int ltdb_index_filter(struct ltdb_private *ltdb,
                                      &dn_list->dn[i],
                                      &keys[num_keys]);
                if (ret != LDB_SUCCESS) {
+                       talloc_free(keys);
                        return ret;
                }
 
@@ -1825,6 +1827,7 @@ static int ltdb_index_filter(struct ltdb_private *ltdb,
                bool matched;
                msg = ldb_msg_new(ac);
                if (!msg) {
+                       talloc_free(keys);
                        return LDB_ERR_OPERATIONS_ERROR;
                }
 
@@ -1845,6 +1848,7 @@ static int ltdb_index_filter(struct ltdb_private *ltdb,
 
                if (ret != LDB_SUCCESS && ret != LDB_ERR_NO_SUCH_OBJECT) {
                        /* an internal error */
+                       talloc_free(keys);
                        talloc_free(msg);
                        return LDB_ERR_OPERATIONS_ERROR;
                }
@@ -1867,6 +1871,7 @@ static int ltdb_index_filter(struct ltdb_private *ltdb,
                }
 
                if (ret != LDB_SUCCESS) {
+                       talloc_free(keys);
                        talloc_free(msg);
                        return ret;
                }
@@ -1881,6 +1886,7 @@ static int ltdb_index_filter(struct ltdb_private *ltdb,
                talloc_free(msg);
 
                if (ret == -1) {
+                       talloc_free(keys);
                        return LDB_ERR_OPERATIONS_ERROR;
                }
 
@@ -1890,6 +1896,7 @@ static int ltdb_index_filter(struct ltdb_private *ltdb,
                         * is the callbacks responsiblity, and should
                         * not be talloc_free()'ed */
                        ac->request_terminated = true;
+                       talloc_free(keys);
                        return ret;
                }