Skip to content

Commit

Permalink
more checks of function returned values when applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
lyokha committed Feb 19, 2020
1 parent cc1aa6f commit ddd924e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ngx_http_custom_counters_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,9 @@ ngx_http_cnt_write_persistent_counters(ngx_http_request_t *r,
return NGX_ERROR;
}

(void) ngx_http_cnt_build_collection(r, cycle, &collection, 1);
if (ngx_http_cnt_build_collection(r, cycle, &collection, 1) != NGX_OK) {
goto cleanup;
}

if (ngx_write_file(&file, collection.data, collection.len, 0) == NGX_ERROR)
{
Expand All @@ -1829,6 +1831,15 @@ ngx_http_cnt_write_persistent_counters(ngx_http_request_t *r,
}

return NGX_OK;

cleanup:

if (ngx_close_file(file.fd) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_ERR, log, ngx_errno,
ngx_close_file_n " \"%V\" failed", &file.name);
}

return NGX_ERROR;
}


Expand Down

0 comments on commit ddd924e

Please sign in to comment.