s4:ldb_map: Don't free ares too early.
authorAndrew Kroeger <andrew@id10ts.net>
Thu, 10 Sep 2009 15:04:47 +0000 (10:04 -0500)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 10 Sep 2009 21:29:56 +0000 (07:29 +1000)
As found when running "make test" with the MALLOC_CHECK_ and MALLOC_PERTURB_
environment variables set.

source4/lib/ldb/ldb_map/ldb_map_outbound.c

index 4487d7e763dd4118f987c49cd7a2c2b75a4f7b92..5f5be89976c3056d97b0f179d0888a840f9d5574 100644 (file)
@@ -1250,15 +1250,15 @@ static int map_remote_search_callback(struct ldb_request *req,
                                                ares->response, LDB_SUCCESS);
                }
 
-               talloc_free(ares);
-
                /* reset the pointer to the start of the list */
                ac->r_current = ac->r_list;
 
                /* no entry just return */
                if (ac->r_current == NULL) {
-                       return ldb_module_done(ac->req, ares->controls,
+                       ret = ldb_module_done(ac->req, ares->controls,
                                                ares->response, LDB_SUCCESS);
+                       talloc_free(ares);
+                       return ret;
                }
 
                ret = map_search_local(ac);