tldap: Only free() ld->pending if "req" is part of it
authorVolker Lendecke <vl@samba.org>
Tue, 11 Aug 2020 14:16:12 +0000 (16:16 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 21 Aug 2020 19:14:32 +0000 (19:14 +0000)
Best reviewed with "git show -U10". We need to check that "req" is
actually the last request that is being freed before freeing the whole
array.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14465

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/lib/tldap.c

index bf5fc05d785eab711e1bc424d6d793e2d6011d3b..9da0e0c086e6a4b9c645bd020f80de5bdb85eed9 100644 (file)
@@ -492,11 +492,6 @@ static void tldap_msg_unset_pending(struct tevent_req *req)
 
        tevent_req_set_cleanup_fn(req, NULL);
 
-       if (num_pending == 1) {
-               TALLOC_FREE(ld->pending);
-               return;
-       }
-
        for (i=0; i<num_pending; i++) {
                if (req == ld->pending[i]) {
                        break;
@@ -511,6 +506,11 @@ static void tldap_msg_unset_pending(struct tevent_req *req)
                return;
        }
 
+       if (num_pending == 1) {
+               TALLOC_FREE(ld->pending);
+               return;
+       }
+
        /*
         * Remove ourselves from the cli->pending array
         */