Commits

Anonymous committed 8d7cafc

Some tweaks to make error handling faster
Fix segfaults in LibXSLT, by restoring old entity handler

  • Participants
  • Parent commits 74ac949

Comments (0)

Files changed (2)

     va_list args;
     SV * sv;
     
-    sv = NEWSV(0,0);
+    sv = NEWSV(0,512);
     
     va_start(args, msg);
     sv_vsetpvfn(sv, msg, strlen(msg), &args, NULL, 0, NULL);
     va_list args;
     SV * sv;
     
-    sv = NEWSV(0,0);
+    sv = NEWSV(0,512);
     
     va_start(args, msg);
     sv_vsetpvfn(sv, msg, strlen(msg), &args, NULL, 0, NULL);
     STRLEN len;
     SV * sv;
     
-    sv = NEWSV(0,0);
+    sv = NEWSV(0,512);
     
     va_start(args, msg);
     sv_vsetpvfn(sv, msg, strlen(msg), &args, NULL, 0, NULL);
     SV * read_results;
     STRLEN read_length;
     char * chars;
-    SV * tbuff = NEWSV(0,0);
+    SV * tbuff = NEWSV(0,len);
     SV * tsize = newSViv(len);
     
     ENTER;
         # warn( "context created\n");
 
         ctxt->_private = (void*)self;
-
-        LibXML_error = newSVpv("", 0);
-
+        
+        LibXML_error = NEWSV(0, 512);
+        sv_setpvn(LibXML_error, "", 0);
+        
         # warn( "context initialized \n");        
         ret = xmlParseDocument(ctxt);
 
         xmlDocPtr real_dom;
         ProxyObject* proxy;
     CODE:
-        LibXML_error = newSVpv("", 0);
+        LibXML_error = NEWSV(0, 512);
+        sv_setpvn(LibXML_error, "", 0);
+        
         real_dom = LibXML_parse_stream(self, fh);
 
         sv_2mortal(LibXML_error);
             croak("Could not create file parser context for file '%s' : %s", filename, strerror(errno));
         }
         ctxt->_private = (void*)self;
-        LibXML_error = newSVpv("", 0);
-
+        
+        LibXML_error = NEWSV(0, 512);
+        sv_setpvn(LibXML_error, "", 0);
+        
         xmlParseDocument(ctxt);
         well_formed = ctxt->wellFormed;
         valid = ctxt->valid;
             croak("Empty string");
         }
         
-        LibXML_error = newSVpv("", 0);
+        LibXML_error = NEWSV(0, 512);
+        sv_setpvn(LibXML_error, "", 0);
         
         real_dom = htmlParseDoc(ptr, NULL);
         
         xmlDocPtr real_dom;
         ProxyObject* proxy;
     CODE:
-        LibXML_error = newSVpv("", 0);
+        LibXML_error = NEWSV(0, 512);
+        sv_setpvn(LibXML_error, "", 0);
+        
         real_dom = LibXML_parse_html_stream(self, fh);
         
         sv_2mortal(LibXML_error);
         xmlDocPtr real_dom;
         ProxyObject * proxy;
     CODE:
-        LibXML_error = newSVpv("", 0);
+        LibXML_error = NEWSV(0, 512);
+        sv_setpvn(LibXML_error, "", 0);
+        
         real_dom = htmlParseFile(filename, NULL);
 
         sv_2mortal(LibXML_error);
 
     xmlGenericErrorFunc error_cb;
     xmlExternalEntityLoader entity_loader_cb;
+    xmlExternalEntityLoader old_entity_loader_cb;
 
     /* then the pseudo sax handler */
     xmlSAXHandlerPtr SAX_handler; /* this is for the time when daniel 
             printf( "%d \n",regtest );
         }
 
+        parser->old_entity_loader_cb = xmlGetExternalEntityLoader();
         xmlSetExternalEntityLoader( parser->entity_loader_cb );
         xmlSetGenericErrorFunc(parser->error_fh, parser->error_cb );
 
     if ( parser != NULL ) {
         xmlSubstituteEntitiesDefaultValue = 1;
         xmlKeepBlanksDefaultValue = 1;
-        xmlSetExternalEntityLoader( NULL );
+        xmlSetExternalEntityLoader( parser->old_entity_loader_cb );
         xmlSetGenericErrorFunc( NULL, NULL );
         xmlGetWarningsDefaultValue = 0;
         xmlLoadExtDtdDefaultValue = 5;
          * callback function off the callback stack
          */
 
+        xmlRegisterInputCallbacks(NULL, NULL, NULL, NULL);
+
 /*         xmlCleanupParser(); */
     }
 }