Fix a valgrind error when the socket dies
authorVolker Lendecke <vl@samba.org>
Tue, 27 Jan 2009 18:41:34 +0000 (19:41 +0100)
committerVolker Lendecke <vl@samba.org>
Wed, 28 Jan 2009 15:18:15 +0000 (16:18 +0100)
Don't reference anything that might have been deleted in the async_req_error
call.

source3/libsmb/async_smb.c

index a1fcf8eb07353b52e261bd03a965bf1b269bd682..a4bbe6d79d59a403a016f0ec12bd4de80206620e 100644 (file)
@@ -1022,7 +1022,7 @@ static void cli_state_handler(struct event_context *event_ctx,
                              struct fd_event *event, uint16 flags, void *p)
 {
        struct cli_state *cli = (struct cli_state *)p;
-       struct cli_request *req;
+       struct cli_request *req, *next;
        NTSTATUS status;
 
        DEBUG(11, ("cli_state_handler called with flags %d\n", flags));
@@ -1128,9 +1128,14 @@ static void cli_state_handler(struct event_context *event_ctx,
        return;
 
  sock_error:
-       for (req = cli->outstanding_requests; req; req = req->next) {
-               int i;
-               for (i=0; i<req->num_async; i++) {
+
+       for (req = cli->outstanding_requests; req; req = next) {
+               int i, num_async;
+
+               next = req->next;
+               num_async = req->num_async;
+
+               for (i=0; i<num_async; i++) {
                        async_req_error(req->async[i], status);
                }
        }