Commits

Anonymous committed 05f292b

Modified Files:
perl-libxml-mm.c
more readable code and sanity checks

Comments (0)

Files changed (1)

     frag   = xmlNewDocFragment( doc );
     retval = PmmNewNode(frag);
 
-    if ( doc ) {
+    if ( doc != NULL ) {
         xs_warn("inc document\n");
-        PmmREFCNT_inc(((ProxyNodePtr)doc->_private));
+        /* under rare circumstances _private is not set correctly? */
+        if ( doc->_private != NULL ) {
+            PmmREFCNT_inc(((ProxyNodePtr)doc->_private));
+        }
         retval->owner = (xmlNodePtr)doc;
     }
 
         }
         break;
     case XML_DTD_NODE:
-        if ( node->doc ) {
+        if ( node->doc != NULL ) {
             if ( node->doc->extSubset != (xmlDtdPtr)node 
                  && node->doc->intSubset != (xmlDtdPtr)node ) {
                 xs_warn( "PFN: XML_DTD_NODE\n");
     ProxyNodePtr owner = NULL;  
     int retval = 0;
 
-    if ( node ) {
+    if ( node != NULL ) {
         retval = PmmREFCNT(node)--;
         if ( PmmREFCNT(node) <= 0 ) {
             xs_warn( "NODE DELETATION\n" );
         xs_warn(" return new perl node\n");
         xs_warn( CLASS );
 
-        if ( node->_private ) {
+        if ( node->_private != NULL ) { 
             dfProxy = PmmNewNode(node);
         }
         else {
 void
 PmmFixOwnerList( xmlNodePtr list, ProxyNodePtr parent )
 {
-    if ( list ) {
+    if ( list != NULL ) {
         xmlNodePtr iterator = list;
         while ( iterator != NULL ) {
             switch ( iterator->type ) {
             break;
         }
 
-        if ( PmmOWNER(nodetofix) ) {
+        if ( PmmOWNER(nodetofix) != NULL ) {
             oldParent = PmmOWNERPO(nodetofix);
         }
         
                 PmmOWNER(nodetofix) = NULL;
             }
             
-            if ( oldParent && oldParent != nodetofix )
+            if ( oldParent != NULL && oldParent != nodetofix )
                 PmmREFCNT_dec(oldParent);
             
             if ( PmmNODE(nodetofix)->type != XML_ATTRIBUTE_NODE
 { 
     xmlParserCtxtPtr libnode = NULL;
     int retval = 0;
-    if ( node ) {
+    if ( node != NULL ) {
         retval = PmmREFCNT(node)--;
         if ( PmmREFCNT(node) <= 0 ) {
             xs_warn( "NODE DELETATION\n" );