Commit e9dc3f4e authored by Tarun Prabhu's avatar Tarun Prabhu

Null pointer checks added to see if those are the cause of assign's seg faults.

parent 7f2e8953
......@@ -13,6 +13,7 @@ static const char rcsid[] = "$Id: annotate.cc,v 1.2 2009-05-20 18:06:07 tarunp E
#ifdef WITH_XML
#include "annotate.h"
#include "common.h"
#include "xstr.h"
#include <string>
......@@ -28,9 +29,17 @@ void annotate::write_annotated_file (const char* filename)
{
// Get the current implementation
DOMImplementation *impl = DOMImplementationRegistry::getDOMImplementation(NULL);
if (!impl) {
cout << "*** Could not create DOMImplementationRegistry" << endl;
exit(EXIT_FATAL);
}
// Construct the DOMWriter
DOMWriter* writer = ((DOMImplementationLS*)impl)->createDOMWriter();
if (!writer) {
cout << "*** Could not create DOMWriter" << endl;
exit(EXIT_FATAL);
}
// Make the output look pretty
if (writer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
......@@ -46,6 +55,10 @@ void annotate::write_annotated_file (const char* filename)
// Construct the LocalFileFormatTarget
XMLFormatTarget *outputFile = new xercesc::LocalFileFormatTarget(filename);
if (!outputFile) {
cout << "*** Could not create output file " << filename << endl;
exit(EXIT_FATAL);
}
// Serialize a DOMNode to the local file "<some-file-name>.xml"
writer->writeNode(outputFile, *dynamic_cast<DOMNode*>(this->document));
......
......@@ -111,8 +111,9 @@ int parse_advertisement(tb_pgraph &pg, tb_sgraph &sg, char *filename) {
/*
* Do the actual parse
*/
XMLDEBUG("Begin XML parse" << endl);
domParser->parse(filename);
//XMLDEBUG("XML parse completed" << endl);
XMLDEBUG("XML parse completed" << endl);
/*
* If there are any errors, do not go any further
......
......@@ -10,6 +10,7 @@
#ifdef WITH_XML
#include "common.h"
#include "rspec_parser_v2.h"
#include "rspec_parser.h"
......@@ -45,7 +46,7 @@ rspec_parser_v2::readLinkInterface (const DOMElement* link, int& ifaceCount)
}
if ((this->ifacesSeen).find(sourceId) == (this->ifacesSeen).end()) {
cerr << "*** Could not find source interface " << sourceId << endl;
exit(-1);
exit(EXIT_FATAL);
}
string destId = "";
......@@ -57,7 +58,7 @@ rspec_parser_v2::readLinkInterface (const DOMElement* link, int& ifaceCount)
}
if ((this->ifacesSeen).find(destId) == (this->ifacesSeen).end()) {
cerr << "*** Could not find destination interface " << destId << endl;
exit(-1);
exit(EXIT_FATAL);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment