s4:dsdb/dirsync: fix potential talloc hierachy problems (bug #9470)
authorStefan Metzmacher <metze@samba.org>
Fri, 7 Dec 2012 18:02:10 +0000 (19:02 +0100)
committerMichael Adam <obnox@samba.org>
Mon, 10 Dec 2012 12:53:46 +0000 (13:53 +0100)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
source4/dsdb/samdb/ldb_modules/dirsync.c

index f75ec521d3ef9576af165e8434deb548933ca319..e7699485083f7742310ad835c4a76f5ce79f626e 100644 (file)
@@ -240,7 +240,7 @@ static int dirsync_filter_entry(struct ldb_request *req,
                talloc_steal(newmsg->elements, el->name);
                talloc_steal(newmsg->elements, el->values);
 
-               talloc_free(msg);
+               talloc_steal(newmsg->elements, msg);
                return ldb_module_send_entry(dsc->req, msg, controls);
        }
 
@@ -653,6 +653,7 @@ skip_link:
                        continue;
                }
        }
+       talloc_steal(newmsg->elements, msg);
 
        /*
         * Here we run through the list of attributes returned
@@ -685,10 +686,9 @@ skip_link:
                if (val > dsc->highestUSN) {
                        dsc->highestUSN = val;
                }
-               talloc_free(msg);
                return ldb_module_send_entry(dsc->req, newmsg, controls);
        } else {
-               talloc_free(msg);
+               talloc_free(newmsg);
                return LDB_SUCCESS;
        }
 }