diff --git a/src/nxt_conn_write.c b/src/nxt_conn_write.c index a2a5737b9..de3712596 100644 --- a/src/nxt_conn_write.c +++ b/src/nxt_conn_write.c @@ -322,6 +322,7 @@ nxt_event_conn_io_sendbuf(nxt_conn_t *c, nxt_buf_t *b, size_t limit) sb.iobuf = iob; sb.nmax = NXT_IOBUF_MAX; sb.sync = 0; + sb.last = 0; sb.size = 0; sb.limit = limit; diff --git a/src/nxt_event_conn_job_sendfile.c b/src/nxt_event_conn_job_sendfile.c index 80a292a0b..1ac81903f 100644 --- a/src/nxt_event_conn_job_sendfile.c +++ b/src/nxt_event_conn_job_sendfile.c @@ -70,6 +70,7 @@ nxt_event_conn_job_sendfile_start(nxt_task_t *task, void *obj, void *data) sb.nmax = 1; sb.sync = 0; sb.size = 0; + sb.last = 0; sb.limit = jbs->limit; if (nxt_sendbuf_mem_coalesce(c->socket.task, &sb) != 0 || !sb.sync) { diff --git a/src/nxt_linux_sendfile.c b/src/nxt_linux_sendfile.c index f5a7dccf2..903ca485f 100644 --- a/src/nxt_linux_sendfile.c +++ b/src/nxt_linux_sendfile.c @@ -60,6 +60,7 @@ nxt_linux_event_conn_io_sendfile(nxt_event_conn_t *c, nxt_buf_t *b, sb.nmax = NXT_IOBUF_MAX; sb.sync = 0; sb.size = 0; + sb.last = 0; sb.limit = limit; niov = nxt_sendbuf_mem_coalesce(c->socket.task, &sb); diff --git a/src/nxt_php_sapi.c b/src/nxt_php_sapi.c index 86b869ed5..70ab264d2 100644 --- a/src/nxt_php_sapi.c +++ b/src/nxt_php_sapi.c @@ -361,13 +361,16 @@ nxt_php_run(nxt_task_t *task, } nxt_memzero(&run_ctx, sizeof(run_ctx)); - + + run_ctx.mem_pool = nxt_mp_create(1024, 128, 256, 32); + if (nxt_slow_path(run_ctx.mem_pool == NULL)) { + return NXT_ERROR; + } + run_ctx.task = task; run_ctx.rmsg = rmsg; run_ctx.wmsg = wmsg; - - run_ctx.mem_pool = nxt_mp_create(1024, 128, 256, 32); - + h = &run_ctx.r.header; rc = nxt_php_read_request(task, rmsg, &run_ctx); diff --git a/src/nxt_process_title.c b/src/nxt_process_title.c index 3c20ac594..6be1ca930 100644 --- a/src/nxt_process_title.c +++ b/src/nxt_process_title.c @@ -116,11 +116,6 @@ nxt_process_arguments(nxt_task_t *task, char **orig_argv, char ***orig_envp) } } - p = nxt_malloc(strings_size); - if (p == NULL) { - return; - } - if (argv_end == end) { /* * There is no reason to modify environ if arguments @@ -130,6 +125,11 @@ nxt_process_arguments(nxt_task_t *task, char **orig_argv, char ***orig_envp) goto done; } + p = nxt_malloc(strings_size); + if (p == NULL) { + goto done; + } + end = argv[0]; for (i = 0; argv[i] != NULL; i++) { @@ -149,7 +149,7 @@ nxt_process_arguments(nxt_task_t *task, char **orig_argv, char ***orig_envp) env = nxt_malloc(environ_size); if (env == NULL) { - return; + goto done; } /* @@ -178,6 +178,12 @@ nxt_process_arguments(nxt_task_t *task, char **orig_argv, char ***orig_envp) } done: + if (p != NULL) { + nxt_free(p); + } + if (env != NULL) { + nxt_free(env); + } /* Preserve space for the trailing zero. */ end--; diff --git a/src/nxt_socketpair.c b/src/nxt_socketpair.c index efa0f4863..ec3bde61c 100644 --- a/src/nxt_socketpair.c +++ b/src/nxt_socketpair.c @@ -232,7 +232,8 @@ nxt_recvmsg(nxt_socket_t s, nxt_fd_t *fd, nxt_iobuf_t *iob, nxt_uint_t niob) msg.msg_iovlen = niob; msg.msg_control = (caddr_t) &cmsg; msg.msg_controllen = sizeof(cmsg); - + msg.msg_flags = 0; + *fd = -1; #if (NXT_VALGRIND) diff --git a/src/nxt_time_parse.c b/src/nxt_time_parse.c index f79c78abf..98d88cf0c 100644 --- a/src/nxt_time_parse.c +++ b/src/nxt_time_parse.c @@ -368,8 +368,6 @@ nxt_term_parse(const u_char *p, size_t len, nxt_bool_t seconds) if (state == st_first_digit) { return -1; } - - state = st_letter; } switch (ch) {