Commits

Anonymous committed 317ff50

Modified Files:
perl-libxml-mm.c
o whitespaces ?

xpath.c
+ initialize all pointers with NULL to avoid bad behaviour with
empty query results or nodes

lib/XML/LibXML/SAX/Builder.pm
[fix] better work with document fragments

Comments (0)

Files changed (3)

lib/XML/LibXML/SAX/Builder.pm

         $self->{NamespaceStack}->push_context;
     }
     return unless $self->{Parent};
-    my $node = $self->{DOM}->createTextNode($chars->{Data});
+    my $node;
+    if ( defined $self->{DOM} ) {
+        $node = $self->{DOM}->createTextNode($chars->{Data});
+    }
+    else {
+        $node = XML::LibXML::Text->new($chars->{Data});
+    }
+
     $self->{Parent}->appendChild($node);
 }
 
     if ( scalar != NULL && scalar != &PL_sv_undef ) {
         STRLEN len;
         char * t_pv =SvPV(scalar, len);
+        xmlChar* ts;
         xmlChar* string = xmlStrdup((xmlChar*)t_pv);
         /* Safefree( t_pv ); */
         
         if ( xmlStrlen(string) > 0 ) {
-            xmlChar* ts;
             xs_warn( "no undefs" );
 #ifdef HAVE_UTF8
             xs_warn( "use UTF8" );
                 xs_warn( "domEncodeString!" );
                 ts= PmmEncodeString( encoding, string );
                 xs_warn( "done!" );
-                if ( string != NULL ) 
+                if ( string != NULL ) {
                     xmlFree(string);
+                }
                 string=ts;
             }
         }
+
         retval = xmlStrdup(string);
         if (string != NULL ) {
             xmlFree(string);
 
 void
 perlDocumentFunction(xmlXPathParserContextPtr ctxt, int nargs){
-    xmlXPathObjectPtr obj, obj2 = NULL;
-    xmlChar *base = NULL, *URI;
+    xmlXPathObjectPtr obj = NULL, obj2 = NULL;
+    xmlChar *base = NULL, *URI = NULL;
 
 
     if ((nargs < 1) || (nargs > 2)) {
 
 xmlNodeSetPtr
 domXPathSelect( xmlNodePtr refNode, xmlChar * path ) {
-    xmlNodeSetPtr rv ;
-    xmlXPathObjectPtr res;
+    xmlNodeSetPtr rv = NULL;
+    xmlXPathObjectPtr res = NULL;
   
     res = domXPathFind( refNode, path );