Commits

ph...@9ae0c189-cd1f-4510-a509-f4891f5cf20d  committed 6fa11df

Modified Files:
t/11memory.t
+ more tests to find out about memory leaks

  • Participants
  • Parent commits 0100aed

Comments (0)

Files changed (1)

File t/11memory.t

             my $parser  = XML::LibXML->new;
 
             check_mem();
-       
+       if(0) {
             foreach my $key ( keys %xmlStrings )  {
                 print "# $key \n";
                 for (1..$times_through) {
             }
             ok(1);
         }
+            my %xmlBadStrings = (
+                "SIMPLE"      => ["<xml1>"],
+                "SIMPLE2"      => ["<xml1>","</xml2>", "</xml1>"],
+                "SIMPLE TEXT" => ["<xml1> ","some text some text some text","</xml2>"],
+                "SIMPLE CDATA"=> ["<xml1> ","<!","[CDATA[some text some text some text]","</xml1>"],
+                "SIMPLE JUNK" => ["<xml1/> ","junk"],
+            );
+
+            print "# BAD PUSHED DATA\n";
+            foreach my $key ( "SIMPLE","SIMPLE2", "SIMPLE TEXT","SIMPLE CDATA","SIMPLE JUNK" )  {
+                print "# $key \n";
+                for (1..$times_through) {
+                    eval {map { $parser->push( $_ ) } @{$xmlBadStrings{$key}};};
+                    eval {my $doc = $parser->finish_push();};
+                }
+
+                check_mem();
+            }            
+
+        }
 
         {
             print "# SAX PUSH PARSER\n";
 
+            my $handler = sax_null->new;
+            my $parser  = XML::LibXML->new;
+            $parser->set_handler( $handler );
+            check_mem();
+
+
         my %xmlStrings = (
             "SIMPLE"      => ["<xml1>","<xml2><xml3></xml3></xml2>","</xml1>"],
             "SIMPLE TEXT" => ["<xml1> ","<xml2>some text some text some text"," </xml2> </xml1>"],
             "NAMESPACES SIMPLE" => ['<xml:xml1 xmlns:x','ml="foo"><xml:xml2','/></xml:xml1>'],
             "NAMESPACES ATTRIBUTE" => ['<xml:xml1 xmlns:xml="foo">','<xml:xml2 xml:foo="bar"/></xml',':xml1>'],
         );
-
-            my $handler = sax_null->new;
-            my $parser  = XML::LibXML->new;
-            $parser->set_handler( $handler );
-
-            check_mem();
        
             foreach my $key ( keys %xmlStrings )  {
                 print "# $key \n";
                 for (1..$times_through) {
-                    map { $parser->push( $_ ) } @{$xmlStrings{$key}};
-                    my $doc = $parser->finish_push();
+                    eval {map { $parser->push( $_ ) } @{$xmlStrings{$key}};};
+                    eval {my $doc = $parser->finish_push();};
                 }
 
                 check_mem();
             }
             ok(1);
+
+            print "# BAD PUSHED DATA\n";
+
+            my %xmlBadStrings = (
+                "SIMPLE "      => ["<xml1>"],
+                "SIMPLE2"      => ["<xml1>","</xml2>", "</xml1>"],
+                "SIMPLE TEXT"  => ["<xml1> ","some text some text some text","</xml2>"],
+                "SIMPLE CDATA" => ["<xml1> ","<!","[CDATA[some text some text some text]","</xml1>"],
+                "SIMPLE JUNK"  => ["<xml1/> ","junk"],
+            );
+
+            foreach my $key ( keys %xmlBadStrings )  {
+                print "# $key \n";
+                for (1..$times_through) {
+                    eval {map { $parser->push( $_ ) } @{$xmlBadStrings{$key}};};
+                    eval {my $doc = $parser->finish_push();};
+                }
+
+                check_mem();
+            }            
         }
 
     }