Skip Menu |

This queue is for tickets about the Graph-Easy CPAN distribution.

Report information
The Basics
Id: 79874
Status: new
Priority: 0/
Queue: Graph-Easy

People
Owner: Nobody in particular
Requestors: BUBAFLUB [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.71
Fixed in: (no value)



Subject: Label with newline causes infinite loop
Hello, If I have a label with a newline I can cause an infinite loop which eventually uses up all the memory available to the perl interpreter. I've tested this on both 5.14.2 and 5.12.3 though at work there is an old 5.8 version which does not exhibit this behavior. Here is the simplest test case: ---------- #!/usr/bin/perl use strict; use warnings; use Graph::Easy; my $graph = Graph::Easy->new(); $graph->add_edge('Test1', 'Test 2'); $graph->add_edge('Test 2', "Test 3\nTest 4\nTest 5"); print $graph->as_ascii_html(); ---------- The infinite loop is in Graph::Easy::Node::_aligned_label in this while loop at line 593: while ($name ne '') { $name =~ s/^(.*?([^\\]|))(\z|\\(n|r|l|c))//; ... } The problem is that the regular expression is not matching a new line character but the two character combinations, \n, \r, \l, and \c. I'm not sure if that was intentional, but if it was I'd recommend changing the regex to: $name =~ s/^(.*?([^\\]|))(\z|\n|\\([nrlc]))//; The modifications include adding \n as a character in the last section and simplifies the n|r|l|c to [nrlc]. If it wasn't intentional and you wanted to check for newline characters I believe you could use the regex class \n or you could change the regex to: $name =~ s/^(.*?([^\\]|))(\z|([\n\r\l\c]))//;