comparison src/http/modules/ngx_http_gzip_filter_module.c @ 7033:ab5117642647

Gzip: fixed style in $gzip_ratio variable handler. The current style in variable handlers returning NGX_OK is to either set v->not_found to 1, or to initialize the entire ngx_http_variable_value_t structure. In theory, always setting v->valid = 1 for NGX_OK would be useful, which would mean that the value was computed and is thus valid, including the special case of v->not_found = 1. But currently that's not the case and causes the (v->valid || v->not_found) check to access an uninitialized v->valid value, which is safe only because its value doesn't matter when v->not_found is set.
author Ruslan Ermilov <ru@nginx.com>
date Wed, 14 Jun 2017 12:49:20 +0300
parents 99934aade555
children 29e9571b1989
comparison
equal deleted inserted replaced
7032:d48c8cdac201 7033:ab5117642647
1082 ngx_http_variable_value_t *v, uintptr_t data) 1082 ngx_http_variable_value_t *v, uintptr_t data)
1083 { 1083 {
1084 ngx_uint_t zint, zfrac; 1084 ngx_uint_t zint, zfrac;
1085 ngx_http_gzip_ctx_t *ctx; 1085 ngx_http_gzip_ctx_t *ctx;
1086 1086
1087 ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module);
1088
1089 if (ctx == NULL || ctx->zout == 0) {
1090 v->not_found = 1;
1091 return NGX_OK;
1092 }
1093
1087 v->valid = 1; 1094 v->valid = 1;
1088 v->no_cacheable = 0; 1095 v->no_cacheable = 0;
1089 v->not_found = 0; 1096 v->not_found = 0;
1090
1091 ctx = ngx_http_get_module_ctx(r, ngx_http_gzip_filter_module);
1092
1093 if (ctx == NULL || ctx->zout == 0) {
1094 v->not_found = 1;
1095 return NGX_OK;
1096 }
1097 1097
1098 v->data = ngx_pnalloc(r->pool, NGX_INT32_LEN + 3); 1098 v->data = ngx_pnalloc(r->pool, NGX_INT32_LEN + 3);
1099 if (v->data == NULL) { 1099 if (v->data == NULL) {
1100 return NGX_ERROR; 1100 return NGX_ERROR;
1101 } 1101 }