diff --git a/src/ExpatXmlParser.cc b/src/ExpatXmlParser.cc index 9673fc29..d0345d3a 100644 --- a/src/ExpatXmlParser.cc +++ b/src/ExpatXmlParser.cc @@ -160,26 +160,26 @@ XML_Parser createParser(SessionData* sd) bool XmlParser::parseFile(const char* filename) { - BufferedFile* fp = 0; if(strcmp(filename, DEV_STDIN) == 0) { - fp = new BufferedFile(stdin); - auto_delete_d deleter(fp); + BufferedFile fp(stdin); return parseFile(fp); } else { - fp = new BufferedFile(filename, BufferedFile::READ); - auto_delete_d deleter(fp); + BufferedFile fp(filename, BufferedFile::READ); return parseFile(fp); } } -bool XmlParser::parseFile(BufferedFile* fp) +bool XmlParser::parseFile(BufferedFile& fp) { + if(!fp) { + return false; + } char buf[4096]; SessionData sessionData(psm_); XML_Parser parser = createParser(&sessionData); auto_delete deleter(parser, XML_ParserFree); while(1) { - size_t res = fp->read(buf, sizeof(buf)); + size_t res = fp.read(buf, sizeof(buf)); if(XML_Parse(parser, buf, res, 0) == XML_STATUS_ERROR) { return false; } diff --git a/src/ExpatXmlParser.h b/src/ExpatXmlParser.h index 26fbcb13..4a4cbc8f 100644 --- a/src/ExpatXmlParser.h +++ b/src/ExpatXmlParser.h @@ -54,7 +54,7 @@ public: bool parseBinaryStream(BinaryStream* binaryStream); bool parseMemory(const char* xml, size_t size); private: - bool parseFile(BufferedFile* fp); + bool parseFile(BufferedFile& fp); ParserStateMachine* psm_; };