Summary
The evhttp_new(base) result is used for the server but never passed to evhttp_free(). Its allocation persists if dispatch returns.
Affected code
- Repository commit:
477033f938fd47dfecde43c82257cd286d9fa38e
- File:
benchmark/http/libevent/libevent_http_bench.c
- Original scanner location: line 159
Evidence
Source: benchmark/http/libevent/libevent_http_bench.c lines 151-175
151: }
152:
153: base = event_base_new_with_config(cfg);
154: if (!base) {
155: fprintf(stderr, "creating event_base failed. Exiting.\n");
156: return 1;
157: }
158:
159: http = evhttp_new(base);
160:
161: content = malloc(content_len);
162: if (content == NULL) {
163: fprintf(stderr, "Cannot allocate content\n");
164: exit(1);
165: } else {
166: int i = 0;
167: for (i = 0; i < (int)content_len; ++i)
168: content[i] = (i & 255);
169: }
170:
171: evhttp_set_cb(http, "/ind", http_basic_cb, NULL);
172: fprintf(stderr, "/ind - basic content (memory copy)\n");
173:
174: evhttp_set_cb(http, "/ref", http_ref_cb, NULL);
175: fprintf(stderr, "/ref - basic content (reference)\n");
Source: benchmark/http/libevent/libevent_http_bench.c lines 181-196
181: evhttp_bind_socket(http, "0.0.0.0", port);
182:
183: #ifdef _WIN32
184: if (use_iocp) {
185: struct timeval tv={99999999,0};
186: event_base_loopexit(base, &tv);
187: }
188: #endif
189: event_base_dispatch(base);
190:
191: #ifdef _WIN32
192: WSACleanup();
193: #endif
194:
195: /* NOTREACHED */
196: return (0);
Impact
The HTTP server object and associated callbacks/listener state remain allocated until process termination.
Summary
The
evhttp_new(base)result is used for the server but never passed toevhttp_free(). Its allocation persists if dispatch returns.Affected code
477033f938fd47dfecde43c82257cd286d9fa38ebenchmark/http/libevent/libevent_http_bench.cEvidence
Source: benchmark/http/libevent/libevent_http_bench.c lines 151-175
Source: benchmark/http/libevent/libevent_http_bench.c lines 181-196
Impact
The HTTP server object and associated callbacks/listener state remain allocated until process termination.