lib/async_req: use tevent_req_nomem/tevent_req_post in read_packet_send()
authorStefan Metzmacher <metze@samba.org>
Thu, 21 May 2015 20:28:14 +0000 (22:28 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 12 Jun 2015 15:08:18 +0000 (17:08 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11316

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

index ebcedb5..19278f6 100644 (file)
@@ -410,19 +410,16 @@ struct tevent_req *read_packet_send(TALLOC_CTX *mem_ctx,
        state->private_data = private_data;
 
        state->buf = talloc_array(state, uint8_t, initial);
-       if (state->buf == NULL) {
-               goto fail;
+       if (tevent_req_nomem(state->buf, req)) {
+               return tevent_req_post(req, ev);
        }
 
        fde = tevent_add_fd(ev, state, fd, TEVENT_FD_READ, read_packet_handler,
                            req);
-       if (fde == NULL) {
-               goto fail;
+       if (tevent_req_nomem(fde, req)) {
+               return tevent_req_post(req, ev);
        }
        return req;
- fail:
-       TALLOC_FREE(req);
-       return NULL;
 }
 
 static void read_packet_handler(struct tevent_context *ev,