aboutsummaryrefslogtreecommitdiff
path: root/nginx/ngx_stream_js_module.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2016-07-21 11:39:00 +0300
committerRoman Arutyunyan <arut@nginx.com>2016-07-21 11:39:00 +0300
commit8048313eeea8e6ac38d2e5ce1ea3075911b57b0f (patch)
tree5ccc72bd031732eaa4bb1b4283fb111cfdd90cd9 /nginx/ngx_stream_js_module.c
parent8c9570dcffe62a8cfa027da408c4c0949ca8c32b (diff)
downloadnjs-8048313eeea8e6ac38d2e5ce1ea3075911b57b0f.tar.gz
njs-8048313eeea8e6ac38d2e5ce1ea3075911b57b0f.zip
Fixed closing file descriptor on error.
Found by Coverity (CID 1364196, 1364197, 1364198, 1364199).
Diffstat (limited to 'nginx/ngx_stream_js_module.c')
-rw-r--r--nginx/ngx_stream_js_module.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/nginx/ngx_stream_js_module.c b/nginx/ngx_stream_js_module.c
index 62273ce0..53dfed26 100644
--- a/nginx/ngx_stream_js_module.c
+++ b/nginx/ngx_stream_js_module.c
@@ -456,6 +456,7 @@ ngx_stream_js_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
if (ngx_fd_info(fd, &fi) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
ngx_fd_info_n " \"%s\" failed", file.data);
+ (void) ngx_close_file(fd);
return NGX_CONF_ERROR;
}
@@ -463,6 +464,7 @@ ngx_stream_js_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
start = ngx_pnalloc(cf->pool, size);
if (start == NULL) {
+ (void) ngx_close_file(fd);
return NGX_CONF_ERROR;
}
@@ -472,16 +474,16 @@ ngx_stream_js_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
ngx_read_fd_n " \"%s\" failed", file.data);
- ngx_close_file(fd);
+ (void) ngx_close_file(fd);
return NGX_CONF_ERROR;
}
if ((size_t) n != size) {
ngx_log_error(NGX_LOG_ALERT, cf->log, 0,
- ngx_read_fd_n " has read only %z of %O from \"%s\"",
+ ngx_read_fd_n " has read only %z of %uz from \"%s\"",
n, size, file.data);
- ngx_close_file(fd);
+ (void) ngx_close_file(fd);
return NGX_CONF_ERROR;
}