[libxml++] DomParser crashes on empty file



Hi folks,

The DomParser appears to have problems with empty files, i.e. there has 
to be at least one character available, otherwise it is producing SEGFAULT
in xmlpp::Document constructor (doc==NULL) ... 
according to the output of gdb when debugging the following program :


int main(int argc, char** argv)
{
   if(argc != 2)
     return 1;
   xmlpp::DomParser P;
   try {
     P.parse_file(argv[1]);
   }
   catch(const xmlpp::exception& e) {
      cerr << "libxml++ exception : " << e.what() << endl;
   }
   return 0;
}


gdb .....
+++++++++++++++++++++++++++++++++++++++++++++
GNU gdb 2003-06-06-cvs-debian
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-linux"...
(gdb) set args /tmp/emptyFile
(gdb) run
Starting program: /home/tmp/test /tmp/emptyFile
[New Thread 16384 (LWP 3427)]
/tmp/emptyFile:1: error: Document is empty

^
/tmp/emptyFile:1: error: Start tag expected, '<' not found

^

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 3427)]
Document (this=0x80f27c0, doc=0x0) at document.cc:177
177     document.cc: Datei oder Verzeichnis nicht gefunden.
        in document.cc
(gdb) where
#0  Document (this=0x80f27c0, doc=0x0) at document.cc:177
#1  0x4021d62a in xmlpp::DomParser::parse_context() (this=0xbffff830) at domparser.cc:87
#2  0x4021d40e in xmlpp::DomParser::parse_file(std::string const&) (this=0xbffff830, filename= 0xbffff820) at domparser.cc:58
#3  0x0804ab25 in main (argc=2, argv=0xbffff8b4) at test.cpp:50

+++++++++++++++++++++++++++

libxml2-version : 2.5.7
libxml++-version : 0.23.0


If that is not a bug, what's the reason for this weird behavior ?

Regards, Jan





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]