src: Zero clear http_parser_url struct

This commit is contained in:
Tatsuhiro Tsujikawa 2014-02-27 22:11:31 +09:00
parent 227a48cea1
commit a85455ed0b
3 changed files with 6 additions and 0 deletions

View File

@ -259,6 +259,7 @@ void check_rewrite_location_uri(const std::string& new_uri,
uint16_t upstream_port) uint16_t upstream_port)
{ {
http_parser_url u; http_parser_url u;
memset(&u, 0, sizeof(u));
CU_ASSERT(0 == http_parser_parse_url(uri.c_str(), uri.size(), 0, &u)); CU_ASSERT(0 == http_parser_parse_url(uri.c_str(), uri.size(), 0, &u));
CU_ASSERT(new_uri == CU_ASSERT(new_uri ==
http2::rewrite_location_uri(uri, u, req_host, http2::rewrite_location_uri(uri, u, req_host,

View File

@ -769,6 +769,7 @@ struct HttpClient {
int level = 0) int level = 0)
{ {
http_parser_url u; http_parser_url u;
memset(&u, 0, sizeof(u));
if(http_parser_parse_url(uri.c_str(), uri.size(), 0, &u) != 0) { if(http_parser_parse_url(uri.c_str(), uri.size(), 0, &u) != 0) {
return false; return false;
} }
@ -917,6 +918,7 @@ void update_html_parser(HttpClient *client, Request *req,
for(auto& p : req->html_parser->get_links()) { for(auto& p : req->html_parser->get_links()) {
auto uri = strip_fragment(p.first.c_str()); auto uri = strip_fragment(p.first.c_str());
http_parser_url u; http_parser_url u;
memset(&u, 0, sizeof(u));
if(http_parser_parse_url(uri.c_str(), uri.size(), 0, &u) == 0 && if(http_parser_parse_url(uri.c_str(), uri.size(), 0, &u) == 0 &&
util::fieldeq(uri.c_str(), u, req->uri.c_str(), req->u, UF_SCHEMA) && util::fieldeq(uri.c_str(), u, req->uri.c_str(), req->u, UF_SCHEMA) &&
util::fieldeq(uri.c_str(), u, req->uri.c_str(), req->u, UF_HOST) && util::fieldeq(uri.c_str(), u, req->uri.c_str(), req->u, UF_HOST) &&
@ -1183,6 +1185,7 @@ int on_frame_recv_callback2
uri += authority; uri += authority;
uri += path; uri += path;
http_parser_url u; http_parser_url u;
memset(&u, 0, sizeof(u));
if(http_parser_parse_url(uri.c_str(), uri.size(), 0, &u) != 0) { if(http_parser_parse_url(uri.c_str(), uri.size(), 0, &u) != 0) {
nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE,
frame->push_promise.promised_stream_id, frame->push_promise.promised_stream_id,
@ -1582,6 +1585,7 @@ int run(char **uris, int n)
requests; requests;
for(int i = 0; i < n; ++i) { for(int i = 0; i < n; ++i) {
http_parser_url u; http_parser_url u;
memset(&u, 0, sizeof(u));
auto uri = strip_fragment(uris[i]); auto uri = strip_fragment(uris[i]);
if(http_parser_parse_url(uri.c_str(), uri.size(), 0, &u) == 0 && if(http_parser_parse_url(uri.c_str(), uri.size(), 0, &u) == 0 &&
util::has_uri_field(u, UF_SCHEMA)) { util::has_uri_field(u, UF_SCHEMA)) {

View File

@ -497,6 +497,7 @@ void Downstream::rewrite_norm_location_response_header
return; return;
} }
http_parser_url u; http_parser_url u;
memset(&u, 0, sizeof(u));
int rv = http_parser_parse_url((*hd).second.c_str(), (*hd).second.size(), int rv = http_parser_parse_url((*hd).second.c_str(), (*hd).second.size(),
0, &u); 0, &u);
if(rv != 0) { if(rv != 0) {