src/os/unix/ngx_readv_chain.c:200: error: Null Dereference
  pointer `iov` last assigned on line 187 could be null and is dereferenced at line 200, column 13.

src/os/unix/ngx_readv_chain.c:176:1: start of procedure ngx_readv_chain()
174. #else /* ! NGX_HAVE_KQUEUE */
175. 
176. ssize_t
     ^
177. ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
178. {

src/os/unix/ngx_readv_chain.c:186:5: 
184.     struct iovec  *iov, iovs[NGX_IOVS];
185. 
186.     prev = NULL;
         ^
187.     iov = NULL;
188.     size = 0;

src/os/unix/ngx_readv_chain.c:187:5: 
185. 
186.     prev = NULL;
187.     iov = NULL;
         ^
188.     size = 0;
189. 

src/os/unix/ngx_readv_chain.c:188:5: 
186.     prev = NULL;
187.     iov = NULL;
188.     size = 0;
         ^
189. 
190.     vec.elts = iovs;

src/os/unix/ngx_readv_chain.c:190:5: 
188.     size = 0;
189. 
190.     vec.elts = iovs;
         ^
191.     vec.nelts = 0;
192.     vec.size = sizeof(struct iovec);

src/os/unix/ngx_readv_chain.c:191:5: 
189. 
190.     vec.elts = iovs;
191.     vec.nelts = 0;
         ^
192.     vec.size = sizeof(struct iovec);
193.     vec.nalloc = NGX_IOVS;

src/os/unix/ngx_readv_chain.c:192:5: 
190.     vec.elts = iovs;
191.     vec.nelts = 0;
192.     vec.size = sizeof(struct iovec);
         ^
193.     vec.nalloc = NGX_IOVS;
194.     vec.pool = c->pool;

src/os/unix/ngx_readv_chain.c:193:5: 
191.     vec.nelts = 0;
192.     vec.size = sizeof(struct iovec);
193.     vec.nalloc = NGX_IOVS;
         ^
194.     vec.pool = c->pool;
195. 

src/os/unix/ngx_readv_chain.c:194:5: 
192.     vec.size = sizeof(struct iovec);
193.     vec.nalloc = NGX_IOVS;
194.     vec.pool = c->pool;
         ^
195. 
196.     /* coalesce the neighbouring bufs */

src/os/unix/ngx_readv_chain.c:198:12: Loop condition is true. Entering loop body
196.     /* coalesce the neighbouring bufs */
197. 
198.     while (chain) {
                ^
199.         if (prev == chain->buf->last) {
200.             iov->iov_len += chain->buf->end - chain->buf->last;

src/os/unix/ngx_readv_chain.c:199:13: Taking true branch
197. 
198.     while (chain) {
199.         if (prev == chain->buf->last) {
                 ^
200.             iov->iov_len += chain->buf->end - chain->buf->last;
201. 

src/os/unix/ngx_readv_chain.c:200:13: 
198.     while (chain) {
199.         if (prev == chain->buf->last) {
200.             iov->iov_len += chain->buf->end - chain->buf->last;
                 ^
201. 
202.         } else {

ssize_t
ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)
{
    u_char        *prev;
    ssize_t        n, size;
    ngx_err_t      err;
    ngx_array_t    vec;
    ngx_event_t   *rev;
    struct iovec  *iov, iovs[NGX_IOVS];
    prev = NULL;
    iov = NULL;
    size = 0;
    vec.elts = iovs;
    vec.nelts = 0;
    vec.size = sizeof(struct iovec);
    vec.nalloc = NGX_IOVS;
    vec.pool = c->pool;
    while (chain) {
        if (prev == chain->buf->last) {
            iov->iov_len += chain->buf->end - chain->buf->last;
        } else {
            if (vec.nelts >= IOV_MAX) {
                break;
            }
            iov = ngx_array_push(&vec);
            if (iov == NULL) {
                return NGX_ERROR;
            }
            iov->iov_base = (void *) chain->buf->last;
            iov->iov_len = chain->buf->end - chain->buf->last;
        }
        size += chain->buf->end - chain->buf->last;
        prev = chain->buf->end;
        chain = chain->next;
    }
    ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
                   "readv: %d:%d", vec.nelts, iov->iov_len);
    rev = c->read;
    do {
        n = readv(c->fd, (struct iovec *) vec.elts, vec.nelts);
        if (n == 0) {
            rev->ready = 0;
            rev->eof = 1;
            return n;
        } else if (n > 0) {
            if (n < size && !(ngx_event_flags & NGX_USE_GREEDY_EVENT)) {
                rev->ready = 0;
            }
            return n;
        }
        err = ngx_socket_errno;
        if (err == NGX_EAGAIN || err == NGX_EINTR) {
            ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,
                           "readv() not ready");
            n = NGX_AGAIN;
        } else {
            n = ngx_connection_error(c, err, "readv() failed");
            break;
        }
    } while (err == NGX_EINTR);
    rev->ready = 0;
    if (n == NGX_ERROR) {
        c->read->error = 1;
    }
    return n;
}
['ssize_t\nngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain)\n{\n    u_char        *prev;\n    ssize_t        n, size;\n    ngx_err_t      err;\n    ngx_array_t    vec;\n    ngx_event_t   *rev;\n    struct iovec  *iov, iovs[NGX_IOVS];\n    prev = NULL;\n    iov = NULL;\n    size = 0;\n    vec.elts = iovs;\n    vec.nelts = 0;\n    vec.size = sizeof(struct iovec);\n    vec.nalloc = NGX_IOVS;\n    vec.pool = c->pool;\n    while (chain) {\n        if (prev == chain->buf->last) {\n            iov->iov_len += chain->buf->end - chain->buf->last;\n        } else {\n            if (vec.nelts >= IOV_MAX) {\n                break;\n            }\n            iov = ngx_array_push(&vec);\n            if (iov == NULL) {\n                return NGX_ERROR;\n            }\n            iov->iov_base = (void *) chain->buf->last;\n            iov->iov_len = chain->buf->end - chain->buf->last;\n        }\n        size += chain->buf->end - chain->buf->last;\n        prev = chain->buf->end;\n        chain = chain->next;\n    }\n    ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,\n                   "readv: %d:%d", vec.nelts, iov->iov_len);\n    rev = c->read;\n    do {\n        n = readv(c->fd, (struct iovec *) vec.elts, vec.nelts);\n        if (n == 0) {\n            rev->ready = 0;\n            rev->eof = 1;\n            return n;\n        } else if (n > 0) {\n            if (n < size && !(ngx_event_flags & NGX_USE_GREEDY_EVENT)) {\n                rev->ready = 0;\n            }\n            return n;\n        }\n        err = ngx_socket_errno;\n        if (err == NGX_EAGAIN || err == NGX_EINTR) {\n            ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,\n                           "readv() not ready");\n            n = NGX_AGAIN;\n        } else {\n            n = ngx_connection_error(c, err, "readv() failed");\n            break;\n        }\n    } while (err == NGX_EINTR);\n    rev->ready = 0;\n    if (n == NGX_ERROR) {\n        c->read->error = 1;\n    }\n    return n;\n}']