Commits

Anonymous committed 9fddf1a

Fixed segfault when files don't exist
Added trap when Create*ParserCtxt returned NULL for all cases

Comments (0)

Files changed (1)

     read_length = LibXML_read_perl(ioref, buffer, 4);
     if (read_length > 0) {
         ctxt = xmlCreatePushParserCtxt(NULL, NULL, buffer, read_length, NULL);
+        if (ctxt == NULL) {
+            croak("Could not create push parser context: %s", strerror(errno));
+        }
         ctxt->_private = (void*)self;
 
         while(read_length = LibXML_read_perl(ioref, buffer, 1024)) {
     CODE:
         ptr = SvPV(string, len);
         ctxt = xmlCreateMemoryParserCtxt(ptr, len);
+        if (ctxt == NULL) {
+            croak("Couldn't create memory parser context: %s", strerror(errno));
+        }
         ctxt->_private = (void*)self;
         
         ret = xmlParseDocument(ctxt);
         STRLEN len;
     CODE:
         ctxt = xmlCreateFileParserCtxt(filename);
+        if (ctxt == NULL) {
+            croak("Could not create file parser context for file '%s' : %s", filename, strerror(errno));
+        }
         ctxt->_private = (void*)self;
         
         xmlParseDocument(ctxt);