r109776 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109775‎ | r109776 | r109777 >
Date:23:02, 22 January 2012
Author:abemusic
Status:ok
Tags:
Comment:
Properly allocate memory following the ngx convention
Modified paths:
  • /trunk/debs/nginx/modules/nginx-udplog/ngx_http_udplog_module.c (modified) (history)

Diff [purge]

Index: trunk/debs/nginx/modules/nginx-udplog/ngx_http_udplog_module.c
@@ -212,29 +212,27 @@
213213 ngx_http_variable_value_t *v, uintptr_t data)
214214 {
215215 u_char *ua;
216 - u_char *eua;
217216 uintptr_t escape;
218 - size_t l;
 217+ size_t l;
219218
220219 ua = r->headers_in.user_agent->value.data;
221 - l = ngx_strlen(ua);
 220+ l = r->headers_in.user_agent->value.len;
222221 escape = 2 * ngx_escape_uri(NULL, ua, l, NGX_ESCAPE_URI);
223222
224 - eua = ngx_pnalloc(r->pool, l + escape);
225 - if (eua == NULL) {
 223+ v->data = ngx_pnalloc(r->pool, l + escape);
 224+ if (v->data == NULL) {
226225 return NGX_ERROR;
227 - }
 226+ }
228227
229 - ngx_escape_uri(eua, ua, l, NGX_ESCAPE_URI);
 228+ ngx_escape_uri(v->data, ua, l, NGX_ESCAPE_URI);
230229
231 - v->data = eua;
232 - v->len = ngx_strlen(eua);
233 -
 230+ v->len = l + escape;
234231 v->valid = 1;
235232 v->no_cacheable = 0;
236233 v->not_found = 0;
237234
238235 return NGX_OK;
 236+
239237 }
240238
241239 static ngx_int_t

Status & tagging log