Skip Menu |

This queue is for tickets about the SuffixTree CPAN distribution.

Report information
The Basics
Id: 11256
Status: resolved
Worked: 30 min
Priority: 0/
Queue: SuffixTree

People
Owner: davido [...] cpan.org
Requestors: samborsky_d [...] yahoo.com
Cc:
AdminCc:

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



Subject: memory leak (tree->tree_string field)
Hi All, I guess I found memory leak in the SuffixTree-0.03: tree->tree_string field is alloced but isn't freed in the suffix_tree.c. The problem can be tested by this script: ############################################## use SuffixTree; my $str = "MACKHGYPDVCPICTAVDVTPGFEYLLLADGEWFP" x 1000; for (my $i = 0; $i < 1000000; $i++) { my $tree = create_tree($str); my $query = "VTP"; my $position = find_substring($tree, $query); printf "%d %d\n", $i, $position; delete_tree($tree); } ############################################## And the problem can be fixed by this patch: --- SuffixTree-0.03/suffix_tree.c.orig 2005-01-27 11:21:22.000000000 +0100 +++ SuffixTree-0.03/suffix_tree.c 2005-01-27 11:22:20.000000000 +0100 @@ -997,6 +997,7 @@ if(tree == 0) return; ST_DeleteSubTree(tree->root); + if (tree->tree_string) free(tree->tree_string); free(tree); } Best regards, Dmitry Samborsky
This has been resolved in version 0.05; An adaptation of your patch was applied. Thanks.