Skip Menu |

This queue is for tickets about the Text-Similarity CPAN distribution.

Report information
The Basics
Id: 29902
Status: resolved
Priority: 0/
Queue: Text-Similarity

People
Owner: Nobody in particular
Requestors: cernst [...] esoft.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.02
Fixed in: (no value)



Subject: Division bt zero bug in Overlaps.pm getSimilarity()
In some cases, $score may be zero and is used to calculate the denominator in a later division. This results in a seg fault due to division by zero. The attached patch will short circuit this case and return zero before the division occurs.
Subject: Overlaps.pm.patch
*** Overlaps.pm.orig 2007-10-10 10:56:09.000000000 -0600 --- Overlaps.pm 2007-10-10 11:04:40.000000000 -0600 *************** *** 139,144 **** --- 139,148 ---- $score += scalar @words * $overlaps->{$key}; } + if ( $score == 0 ) { + return $score; + } + if ($self->normalize) { if ($self->verbose) { print "wc 1: $wc1\n";
Thanks very much for finding this problem and posting this useful fix. Text-Similarity development has been on hiatus for a while, but we'll be doing some clean up in the near future and we'll make sure to include this patch (with credit given of course). Cordially, Ted On Wed Oct 10 13:29:40 2007, cernst wrote: Show quoted text
> In some cases, $score may be zero and is used to calculate the > denominator in a later division. This results in a seg fault due to > division by zero. > > The attached patch will short circuit this case and return zero before > the division occurs.
We have released Text-Similarity 0.03 as of last night, and it includes the divide by zero fix. There is a test case present to verify that it's working, and we've also improved the AllWords.pm synopsis to provide code you can cut and paste to run. Thanks again! Ted On Wed Mar 19 14:11:24 2008, TPEDERSE wrote: Show quoted text
> Thanks very much for finding this problem and posting this useful fix. > Text-Similarity development has been on hiatus for a while, but we'll be > doing some clean up in the near future and we'll make sure to include > this patch (with credit given of course). > > Cordially, > Ted > > On Wed Oct 10 13:29:40 2007, cernst wrote:
> > In some cases, $score may be zero and is used to calculate the > > denominator in a later division. This results in a seg fault due to > > division by zero. > > > > The attached patch will short circuit this case and return zero before > > the division occurs.
>
This bug was corrected in Text-Similarity 0.03, and a test case added to verify the fix.