nghttp: Fix crash if attrs parameter of get_attr() is nullptr

This commit is contained in:
Tatsuhiro Tsujikawa 2013-09-26 22:56:26 +09:00
parent 59397e80be
commit bfe7a9af00
1 changed files with 4 additions and 1 deletions

View File

@ -48,12 +48,15 @@ HtmlParser::~HtmlParser()
namespace { namespace {
const char* get_attr(const xmlChar **attrs, const char *name) const char* get_attr(const xmlChar **attrs, const char *name)
{ {
if(attrs == nullptr) {
return nullptr;
}
for(; *attrs; attrs += 2) { for(; *attrs; attrs += 2) {
if(util::strieq(reinterpret_cast<const char*>(attrs[0]), name)) { if(util::strieq(reinterpret_cast<const char*>(attrs[0]), name)) {
return reinterpret_cast<const char*>(attrs[1]); return reinterpret_cast<const char*>(attrs[1]);
} }
} }
return 0; return nullptr;
} }
} // namespace } // namespace